母版頁的內容頁導入css方法
方法
/// <summary>
/// 在内容页导入css
/// </summary>
/// <param name="page">当前页面</param>
/// <param name="cssPath">css样式路径</param>
public static void AddStyleSheet(Page page, string cssPath)
{
HtmlLink link = new HtmlLink();
link.Href = cssPath;
link.Attributes["rel"] = "stylesheet";
link.Attributes["type"] = "text/css";
page.Header.Controls.Add(link);
}
/// 在内容页导入css
/// </summary>
/// <param name="page">当前页面</param>
/// <param name="cssPath">css样式路径</param>
public static void AddStyleSheet(Page page, string cssPath)
{
HtmlLink link = new HtmlLink();
link.Href = cssPath;
link.Attributes["rel"] = "stylesheet";
link.Attributes["type"] = "text/css";
page.Header.Controls.Add(link);
}
調用:
AddStyleSheet(this.Page, "樣式表路徑");