在内容页当中定义一个类然后调用内中的方法即可

 public static class addstyle{  //可以不用实例化

  public static void addstylesheet(Page page,string path)

{

    HtmlLink link=new HtmlLink();

    link.href=path;

    link.Attributes["rel"]="stylesheet";

    link.Attributes["type"]="css/text";

    page.header.Control.add(link);

}

}

  然后再自己的内容页中调用该静态方法

例protected void page_load(Object sender,EventArgs e)

{

 if(!ispostback)

{

 addstyle.addstylesheet(this.page,"file.css");

 }

}

 

相关文章:

  • 2021-10-05
  • 2022-12-23
  • 2021-12-16
  • 2021-09-23
  • 2022-12-23
  • 2021-07-31
  • 2022-02-11
猜你喜欢
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案