ASP.NET anchor link in user control

.........................................................

Ran into a strange bug today while trying to make an anchor link inside a user control i ASP.NET. The obvious way to do it would be to just to put the anchor ID inside the NavigateUrl attribute of the HyperLink control like NavigateUrl=”#anchor”. That however resulted in the link and anchor pointing to the directory where the user control was located.

So I tried to put the application root modifier in front of the anchor like NavigateUrl=”~/#anchor”. That resulted in the anchor being printed twice in the resulting link, Default.aspx#anchor#anchor. This must be a bug for I can’t imagine any sane use for this kind of behavior.

The solution I came up with was to construct the anchor link manually in my code behind file.

~ End Article and Begin Conversation ~

~ Now It's Your Turn ~

Feel free to use <strong>, <em>, and <a href="">

[]

The Blogroll

Search this Site


[]