2013-02-21 58 views

回答

1

另一種解決方案(不需要的jQuery)被增加一個配置屬性到主頁這樣的:

Site.Master.cs

private bool _IncludeOtherCss = true; 
public bool IncludeOtherCss { 
get { return _IncludeOtherCss; } 
set { _IncludeOtherCss = value; } 
} 

的Site.Master(頭部區段)

<%if (IncludeOtherCss) 
    { %> 
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /> 
    <%} %> 

其他頁面:

protected void Page_Init(object sender, EventArgs e) 
     { 
      (Master as SiteMaster).IncludeOtherCss = false; 
     } 
3

這不是很「優雅」,但你可以使用jQuery腳本來操作和移除鏈接:

<script type="text/javascript"> 
     $(document).ready(function() { 
      $("link[type='text/css']").remove(); 
     }); 
    </script> 

您可以使用jQuery選擇來優化搜索。即

$("link[href='Styles/Site.css']").remove(); 
+0

好的。我在哪裏需要提及css文件的名稱? – 2013-02-21 10:49:35

+0

我更新了答案。 – 2013-02-21 10:52:14

+0

感謝您的幫助將嘗試一下...非常感謝 – 2013-02-21 10:53:25

相關問題