开发者

Registering jQuery-script on master page code-behind doesn't affect scripts on MasterPage

开发者 https://www.devze.com 2023-01-16 03:17 出处:网络
in my .net-Project, I use a master page on which I dynamically register the jQuery-library. public partial class Application : System.Web.UI.MasterPage

in my .net-Project, I use a master page on which I dynamically register the jQuery-library.

public partial class Application : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager.RegisterClientScriptInclude(this, this.GetType(), "jquery", VirtualPathUtility.ToAbsolute("~/Materials/Scripts/jquery-1.4.2.min.js"));
    }     
}

I found out that this works for all pages that are bound to the master page, but that a script on the master page itself throws an error. I still have to use a hardcoded link to get it working. I 开发者_开发技巧would like to understand better why this is so, what´s the problem and how one could get around this.


It seems necessary to reference the script in the markup of the master page.

Link to a similar question

0

精彩评论

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