Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Links in Master Pages

Status
Not open for further replies.

iaresean

Programmer
Joined
Mar 24, 2003
Messages
570
Location
ZA
Hey All;

I am using master pages. My master page contains my header div along with some links for navigating the site. This master page is in the root folder of my site.

I then have pages that inherit from this master page in various folders throughout the site.

However, my problem is that I can't use relative pathing when I define the URLs in my master page. This is because the files that use the master page aren't in the same folder as the master page so the relative link is no longer valid. This because when the page is compiled the relative link acts relative to the file inheriting the master page, and not the master page itself.

An alternative to this would be to use absolute url links, however, this will just give me headaches when switching between development and live.

Is there any way I can force the links to remain relative links to the master page, and not to the inheriting pages.

Thanks for any and all help in this matter.





Sean. [peace]
 
There are various ways but you'll have to experiment to find which way best suits your application. Some examples will be:
Code:
<a href="~/home.aspx">Home</a>
<a href="../home.aspx">Home</a>



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi ca8msm;

I can't use the the relative (..) solution as per my problem description.

What does the ~ character mean?

Thank you for any and all help!

Sean. [peace]
 
The tilde (~) is basically a shortcut to the HttpRuntime.AppDomainAppVirtualPath property which returns the root of the virtual application (not the root of the web server).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top