Recently I was building a site that used common search engine optimization practices of using named directories instead of pages with .aspx or .html extensions. I also was using nested master pages. This is why. Here is a brief structure of the site.
Home
Services directory
Tax directory
Property Tax directory
Specialties directory
Business Tax directory
Facilites directory
Contact directory
For the Services and Specialties directory I used the nested master pages due to each section having different sub navigation. Because the nested master pages and the pages in the directories are not in the same directory as the main master page the links to the images did not work. I needed to find a way for the links to always work no matter what directory the pages were in. This is the code I found from msdn.com
<%=System.Web.VirtualPathUtility.ToAbsolute("~")%>/directory/default.aspx
It can be used for mapping the path to images or mapping links.
a href="<%=System.Web.VirtualPathUtility.ToAbsolute("~")%>/directory/default.aspx"
img src="<%=System.Web.VirtualPathUtility.ToAbsolute("~")%>/images/pic.gif"
Search
Saturday, February 13, 2010
Subscribe to:
Posts (Atom)