开发者

Asp.net MVC : Registerstartupscript

开发者 https://www.devze.com 2023-02-02 15:57 出处:网络
开发者_运维技巧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
开发者_运维技巧

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号