从一页导航到另一页 [英] Navigating from one page to another page

查看:97
本文介绍了从一页导航到另一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的主页上有一些链接,现在我想通过此链接导航到页面,一些页面存储在文件夹中.当我导航到存储在文件夹中的页面时,这让我很满意,但是我的问题是,当我尝试从该页面导航到存储在根目录中的其他页面时,它不会转到正确的页面仅在该文件夹中搜索该页面.
这是我的代码:-

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:-

<a href="Default.aspx">Home</a>
<a href="AboutUs.aspx">About Us</a>
<a href="Secure_Page/Products.aspx">Products</a>


在这里,当我位于Secure_Page文件夹中的Product.aspx页面上时,我想转到Default.aspx或该文件夹之外可用的任何其他页面.我该如何解决这个问题?

在此先感谢您.


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.

推荐答案

您也可以始终使用域名来完全限定链接.

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

<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.


Steve已经回答了您解决问题的一种方法,但也建议您提出另一种方法.

显然是相对路径问题.您需要确保路径正确,以便找到并使用该文件.

我建议您使用此技巧并在设置源之前正确解析路径:
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[^]


解析URL时请使用〜.它将始终转到应用程序的根目录.

例子

〜/somedirectory/default.aspx

将解决...

{applicationRoot}/somedirectory/default.aspx
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


这篇关于从一页导航到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆