Can we avoid few of the CSS files which are there in master page to load in the content pages?

送分小仙女□ 提交于 2019-12-11 08:43:27

问题


Basically what i want to say is can we decide among the list of css files defined in master page which one to load in content pages.

Generally whatever CSS and JS files we define in master pages we can see their behavior in content pages can we control this behavior


回答1:


You can run through your registered links like this:

var links=this.Header.Controls.OfType<HtmlLink>();

typically, you can do that in the oninit of your page. Then you can add/remove/modify registered css or javascript.




回答2:


I have a content area in my master page I call "AdditionalStyles", placed in the head section. This way any page using that master page can add its own style sheets.

Master page:

<head> 
...
<asp:ContentPlaceHolder runat="server" ID="additionalStyles"></asp:ContentPlaceHolder>
...
</head>

Child page:

<asp:Content ContentPlaceHolderID="additionalStyles" runat="server">
<link href="/css/specialstyle.css" rel="stylesheet" type="text/css" />
</asp:Content>



回答3:


If certain pages require certain CSS files then have you thought about nested master pages?

Have 1 master page where all page inherit from then master pages below that, where there are more defined CSS files or more that are specific to a group of other pages.




回答4:


And what is a problem? If you need to load different css's on some params (func params) use just a theming. Or just get in conclusion with your params and make differences in css's.



来源:https://stackoverflow.com/questions/8600772/can-we-avoid-few-of-the-css-files-which-are-there-in-master-page-to-load-in-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!