NavigateUrl="#" becomes href="SubFolder/#"??

Posted by jamietre on Stack Overflow See other posts from Stack Overflow or by jamietre
Published on 2011-01-06T20:20:33Z Indexed on 2011/01/06 20:54 UTC
Read the original article Hit count: 184

Filed under:

This isn't exactly Fermat's last theorem, but it keeps coming back to annoy me like an unpaid phone bill from college. Sometimes I want to create a HyperLink that does not cause a postback, so I want the target url to be #. When the markup happens to be from a UserControl in a subfolder,

/
|- Home.aspx (uses UC.ascx)
|- Sub
   |- UC.ascx

the URL is rewritten with a relative path, e.g.

<asp:HyperLink runat="server" NavigateUrl="#" >Click Me!</asp:HyperLink>

becomes

<a href="SubFolder/#">Click Me!</a>

Which is, unfortunately, wrong. Obviously I can get around this by not using a server control, but it seems stupid. Can this be avoided?

The point here is I will add a click event with jQuery or in code-behind, and I never want it to cause a postback, but I want it to be a hyperlink for CSS reasons.

© Stack Overflow or respective owner

Related posts about ASP.NET