anchor - rendering #

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
 
N

Nathan Sokalski

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,104
Latest member
LesliVqm09
Top