Masterpages and CSS Attached Files

I have two main files. Main.Master and search.Master.

Search.Master is a nested master page that is "inside" of main.Master. For my CSS files to work with masterpages, I had to put the runat = "server" attribute. Like this:

<link runat="server" href="~/mp/css/master.main.css" rel="stylesheet" type="text/css" />

And it works great on the home page. However, this nested master page has its own styles, so I tried again with the runat = "server" trick. I made sure my asp: content was inside and printed:

<link runat="server" href="~/mp/css/master.search.css" rel="stylesheet" type="text/css" />

However, when I checked the source code of my site, the path shown there was:

~ / tr / CSS / master.search.css

Insert

../../tr/CSS/master.search.css

Does anyone know why this is happening? And how to solve it?

PS: <% = ResolveClientUrl ( "bla bla bla" )% > , /. CSS ServerSide.

+3
3

, , , ASPX- GenericControl, , HtmlLink.

href . HtmlLink HREF, URL.

, , :

  • <%=ResolveUrl("blah")%> <%=ResolveClientUrl("blah")%>

  • , URL-, .

+3

, . , , System.Web.UI.HtmlControls.HtmlLink , Href rel ( , ), ContentPlaceHolder.

0

CSS ( , ContentPlaceHolder), CSS . URL- . runat, ~. , :

<link href="../../res/css/styleForThisParticularMasterPage.css" rel="stylesheet" type="text/css" />
0

Source: https://habr.com/ru/post/1721537/


All Articles