How to use Registerstartupscript in my project ? Is it any soluction for that ?
In ASP.NET MVC, you have full control over the markup being produced. If you need a script to be included on the page, simply do it using vanilla HTML/JavaScript.
There really should be no need for RegisterStartupScript in ASP.NET MVC.
inHTML Code :
<%@ Import Namespace="MvcTest.HelperExtension" %>
<script src="<%= Url.jQueryUI("jquery.ui.accordion.min.js")%>" type="text/javascript"></script>
. . . .
in Code :
public static class UrlHelperExtension
{
public static string jQuery(this UrlHelper helper, string fileName)
{
return helper.Content(string.Format("~/Content/Scripts/{0}", fileName));
}
}
Take a look here http://www.codeproject.com/Articles/38936/Using-WebControls-In-ASP-NET-MVC-Views-Part-3.aspx
精彩评论