How to include jquery in masterpage header without path problems?

前端 未结 2 344
野趣味
野趣味 2021-01-21 08:09

I have tried this


Back Office


        
2条回答
  •  长发绾君心
    2021-01-21 08:52

    It seems that, you are trying to add controls to page dynamically. In this case, you can use the below code

    var control = new HtmlGenericControl("script") ;
    control.Attributes.Add("type", "text/javascript");
    control.Attributes.Add("src", Page.ResolveClientUrl("~/scripts/jquery-1.5.1.min.js"));
    //CDN will be best while hosting the application
    //control.Attributes.Add("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js");
    this.Page.Header.Controls.Add(control);
    

提交回复
热议问题