Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I am a beginner in asp.net c# and i am having a problem using anchor tag. I am having a aspx page inside a folder named unlogged and i am trying to direct to that page when i click on the anchor tag.

I tried using this
XML
<a href="unlogged/plotadlisting.aspx">Admin</a>


But i am getting error "The resource cannot be found."

Can someone help me.Thank you in advance.god bless you
Posted
Comments
King Fisher 2-Apr-14 7:13am    
both pages at same folder?

Use just tild before path
XML
<a href="~/unlogged/plotadlisting.aspx">Admin</a>
 
Share this answer
 
Comments
faizel s 2-Apr-14 6:56am    
i also tried that .but still problem persist.Can you suggest me any other way
[no name] 2-Apr-14 7:00am    
use ../ except of ~/
I guess you are trying to work with relative paths or relative urls. In that case, you use "~" or ".." for accessing the parent folders. "~" signs refers to the root directory whereas "..." refers to the parent directory.

So for example I have a directory structure as:

MyWebApplication
+ bin
+ Admin
--* UserManagement.aspx
--* ChangePassword.aspx
--* so on
+ unlogged
--* plotadlisting.aspx
--* so on
+ so on

Now I have an anchor tag inside the page UserManagement.aspx which refers to the unloged/plotadlisting.aspx, then its href attribute would be

<a href='../unloged/plotadlisting.aspx' /> or <a href='~/unloged/plotadlisting.aspx' />

Now here ".." and "~" are one and the same since the parent directory to unloged folder is the root directory itself.

But if my directory structure was

MyWebApplication
+ bin
+ Modules
--+ Admin
----* UserManagement.aspx
----* ChangePassword.aspx
----* so on
+ Other pages
--+ unlogged
----* plotadlisting.aspx
----* so on
+ so on

then the anchor tag's(the one inside UserManagement.aspx) href would have been:

<a href='../../Other pages/unloged/plotadlisting.aspx' /> or <a href='~/Other pages/unloged/plotadlisting.aspx' />


Hope this solution helps you out. If you want to find more on "Relative URLs" then google is the best candidate...
 
Share this answer
 

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