reza reza - 3 years ago 168
ASP.NET (C#) Question

how to add some conditional code for redirect to page in asp.net

I have a

Confirm-user.aspx
in asp.net bound to master page. The Confirm-user page is in folder(Manage_pages). I have the sidebar in master page and use this code for list all page that user can access:

<div id="sidebar">
<ul>
<li>
<h2>title</h2>
<ul>
<% foreach (DAL.Page page in pageList)
{%>
<% Response.Write("<li><a href="+page.PageAddress+">"+page.PageName+"</a></li>"); %>
<% }%>
</ul>
</li>
</ul>
</div>


The problem is that when I click on Confirm-user page link I go to this page successfully:

http://localhost:2112/Manage_pages/ConfirmUser.aspx


But when I click on link again it does not work and go to:

http://localhost:2112/Manage_pages/Manage_pages/ConfirmUser.aspx


Please help me!

Answer Source

use

<a href='<%=ResolveClientUrl("~/ConfirmUser.aspx")%>'>text</a>

the "~/ConfirmUser.aspx" could be "~/Manage_pages/ConfirmUser.aspx" if Manage_pages is your intended sub folder but not your application name

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download