When it executes, a master page is first merged with one of its content pages, and this merge is then rendered in the folder of the content page. This means that all relative paths in the master page become relative to the folder of the content page, and that these paths will be broken if the master page and content page do not reside in the same folder.
Relatives paths should still be used in master pages, but we have to make them relative to our website's root, and let ASP.NET resolve them when the master page executes :
<img src="<%=ResolveUrl("~/images/logo.gif")%>">
The ResolveUrl method is not available in the HEAD section of the master page, but marking this element with runat="server" ensures that the CSS style sheets are linked properly.
Thursday, July 10, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment