Question

I have a user control with a hyperlink control within it. The application is database driven (it's kentico).

I need set to set the hyperlink's navigateurl property to #section-1. When I do so, asp.net is converting the user to /myfolder/usercontrols/#section-1. That's not even the URL that was in the browser, and breaks some existing javascript code I'm working with.

How can I easily get the hyperlink's navigateurl property to render as a clean "#section-1"?

Yes, I need a server side control.

If I build the full request URL manually, even with "~/...", asp.net renders it as a server relative URL, when I just want a clean href="#section-1".

Was it helpful?

Solution

Have you tried:

HyperLink1.Attributes.Add("href","#section-1")

or

HyperLink1.Attributes("href") = "#section-1" 'overwrite any existing href

OTHER TIPS

How about:

hypTheLink.NavigateUrl = Request.Url.PathAndQuery + "#JumpMark";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top