Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
I have some links on my master page, now i want to navigate to pages by this link, some pages are stored in folders. When i am navigating to the page that is stored in folder, it takes me their perfectly but My problem is that when i am trying to navigate from this page to other page that is stored in root directory, it is not going to proper page instead of it is searching for that page in that folder only.
here is my code:-
HTML
<a href="Default.aspx">Home</a>
<a href="AboutUs.aspx">About Us</a>
<a href="Secure_Page/Products.aspx">Products</a>

here when i am on Product.aspx page that is in Secure_Page folder, i want to go to Default.aspx or any other page that is available out side the folder. How can i solve this problem?

Thanks in advance.
Posted
Updated 11-Jul-12 7:00am
v2

You could always fully qualify the link with the domain name as well.

XML
<a href="http://sitename.com/Default.aspx">Home</a>
<a href="http://sitename.com/AboutUs.aspx">About Us</a>
<a href="http://sitename.com/Secure_Page/Products.aspx">Products</a>


or in the code behind for the masterpage you could have it write out that block with a ../ added if you are in the subfolder. The links could always just be generated in the code behind and you can customise them how you want.

Good Luck.
 
Share this answer
 
Comments
Sandeep Mewara 11-Jul-12 13:27pm    
Yep. My 5!
Raje_ 11-Jul-12 13:30pm    
Thanks Steve I got it.
Steve has already replied you with one of the way to resolve your issue, but would like to suggest another one too.

It clearly is relative path issue. You would need to make sure that the path is correct such that file is found and used.

I would suggest you to use this Tip and resolve the path correctly before setting the source: Resolving Paths in a Multi-Folder WebSite[^]
 
Share this answer
 
Comments
Steve Maier 11-Jul-12 13:33pm    
Nice tip. That can definately come in handy.
Sandeep Mewara 11-Jul-12 15:32pm    
Thanks Steve.
Raje_ 11-Jul-12 13:33pm    
Thanks Sandeep.
Sandeep Mewara 11-Jul-12 15:32pm    
Welcome.
Use the ~ when you resolve the url. It will always go to the application root.

Example

~/somedirectory/default.aspx

will resolve to...

{applicationRoot}/somedirectory/default.aspx
 
Share this answer
 
Comments
Raje_ 11-Jul-12 13:37pm    
thanks abhinav, i solved my problem, but as you said use ~(tilde) sign, but as far as i know it can be used only with server controls here i am using a href html control.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900