如何使用锚标记指向文件夹内的页面 [英] how to direct to page inside a folder using anchor tag
本文介绍了如何使用锚标记指向文件夹内的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是asp.net c#的初学者,我在使用锚标签时遇到了问题。我在一个名为unlogged的文件夹中有一个aspx页面,当我点击锚标签时我正试图指向那个页面。
我尝试使用这个
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
<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
推荐答案
在路径前使用tild
Use just tild before path
<a href="~/unlogged/plotadlisting.aspx">Admin</a>
我猜您正在尝试使用相对路径或相对网址。在这种情况下,您使用〜或..来访问父文件夹。 〜符号表示根目录,而...表示父目录。
例如,我有一个目录结构:
MyWebApplication
+ bin
+ Admin
- * UserManagement.aspx
- * ChangePassword.aspx
- *等等
+未登记
- * plotadlisting.aspx
- *等等
+等等
现在我在页面UserManagement中有一个锚标签。 aspx指的是unloged / plotadlisting.aspx,那么它的href属性将是
< a href ='.. / unloged / plotadlisting.aspx'/ gt ;或者< a href ='〜/ unloged / plotadlisting.aspx'/>
现在这里..和〜是同一个unloged文件夹的父目录是根目录本身。
但如果我的目录结构是
MyWebApplication
+ bin
+模块
- + Admin
---- * UserManagement.aspx
---- * ChangePassword.aspx
---- *等等
+其他页面
- - +未登记
---- * plotadlisting.aspx
---- *等等
+等等
然后锚标签(UserManagement.aspx中的一个)href会是:
< a href =' ../../其他页面/ unloged / plotadlisting.aspx'/>或者< a href ='〜/其他页面/ unloged / plotadlisting.aspx'/>
希望此解决方案可以帮助您出。如果你想在相对网址上找到更多信息,那么谷歌是最好的候选人......
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...
这篇关于如何使用锚标记指向文件夹内的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文