在asp.net页面中我不想每个页面都去用link去引用样式,而是想将其封装在一个cs文件中,只要哪个页面需要用样式则在后台类中继承这个cs,   如下:
     public partial class Knowledge :BasePage那么样式就会自动加载到当前页面中,不知道该怎么去实现呢??谢谢了

解决方案 »

  1.   

    方法有很多种,你可以写在基类里面
    方法1
          Literal r = new Literal();
          r.Text = "<link  href=....";      
          this.Header.Controls.Add(r);方法2
          this.ClientScript.RegisterClientScriptBlock(this.GetType(), "x", "<link  href=....", false);
      

  2.   

     ScriptManager.RegisterClientScriptInclude()
      

  3.   

    也可以写在基类里面
    this.StyleSheetTheme属性也是用来控制样式的。你可以参考msdn
      

  4.   

    使用Themes在webconfig里面加上
    <pages theme="主题文件名" styleSheetTheme="样式文件名">