I have a page on my site, for the purposes of this example, you can say http: //myhost/Pages/Default.aspx . In Default.aspx I have a MyControl.ascx user control that is located in /Controls/MyControl.ascx. So the tree looks something like this.
Whenever I put a HyperLink control in MyControl.ascx and point to NavigateUrl, this path refers to the control, not the page URL. So, for example, if I specified “AboutMe.aspx” in NavigateUrl, the URL will display as http: //myhost/Controls/AboutMe.aspx instead of http: //myhost/Pages/AboutMe.aspx . Is there any way to do this regarding the page url? I tried the solution here: Relative path from ASP.NET NavigateUrl user control , but this did not work for me.
Edit
To clarify, I would like it to be general enough so that if I didn’t know what the path would be, the solution would work. Therefore, I really do not want to specify "~ / Pages / Default.aspx" in NavigateUrl
Kyle
source share