asp.net在使用母版页的内容页面中动态加载css和js文件的方法

  protected void Page_Load(object sender, EventArgs e)

  {

          HtmlGenericControl autoCompleteScript = new HtmlGenericControl("script");

          autoCompleteScript.Attributes.Add("type", "text/javascript");

          autoCompleteScript.Attributes.Add("src", "/js/autocomplete/jquery.autocomplete.js");

          Page.Header.Controls.Add(autoCompleteScript);

 

          HtmlLink autoCompleteCss = new HtmlLink();

          autoCompleteCss.Href = "/js/autocomplete/jquery.autocomplete.css";

         autoCompleteCss.Attributes.Add("rel", "stylesheet");

         autoCompleteCss.Attributes.Add("type", "text/css");

         Page.Header.Controls.Add(autoCompleteCss);

}


你可能感兴趣的:(asp.net)