I have a menu made up of html <a>
tags to link to the different pages. The pages are in different folders in the project. Some of the pages are in sub folders. When running in Visual Studio the hrefs are written like this:
/Folder1/Page1.aspx
/Folder2/SubFolder1/Page2.aspx
and the navigation works fine between all the pages. However when I run from the IIS with hrefs written that way, I get an error that pages are not found and the address shown is without the application name.
I tried prefixing the hrefs with ../
, which worked fine until I got to a page in a sub folder and wanted to navigate to a page outside of that parent folder like in the example above from Page2 to Page1, the page is not found because the address is prefixed with Folder2 like this /Folder2/Folder1/Page1.aspx
.
Is it possible to navigate between pages in different folders and sub folders at different levels using <a>
tags?
答案 0 :(得分:0)
我尝试了asp.net HyperLink控件。每个NavigateUrl
都以~/
为前缀,如下所示:
~/Folder1/Page1.aspx
~/Folder2/SubFolder1/Page2.aspx
有效。
但在href
代码中加<a>
前缀不会有效。