anchor - rendering #

  • Thread starter Thread starter KC
  • Start date Start date
K

KC

Is there anyway to tell an HtmlAnchor or Hyperlink cotroll to *not* turn a
"#" in the href into the page or control page location.

For example, when I place
<a runat="server" id="tabLink" href="#"></a>, the link that is rendered is
http://mysite/usercontrols/# . I want only "#" to be rendered. Is this
possible? I tried declaratively and via the code behind and ASP.NET seems
to be intercepting this and turning into the link I described above.

TIA,
kc
 
Did you try a View Source for the page that is rendered? When you say it is
rendering http://mysite/usercontrols/# is that what you see in the browser's
Status Bar or the rendered code? If the rendered code really is just
href="#" then it will send you to http://mysite/usercontrols/# because
relative URLs send you to <current directory><relative url> . Because using
href="#" is interpreted as a relative url, the result is
http://mysite/usercontrols/# when no filename is in the Url. If you would
like the result to be http://mysite/usercontrols/currentpage.aspx# then use
href="currentpage.aspx#" . My recommendation is to avoid using href="#"
(always place a filename there, if you want to place the # after the
filename, go ahead). But also, since you are obviously using ASP.NET, why
don't you just generate and assign the href property with each postback
(it's not hard, if you don't know how to do it, let me know). Good Luck!
 
Back
Top