views:

101

answers:

3

I never saw that problem and I have no idea what is causing it.

I got something like this code in my masterpage

<div class="myClass1">
    <a href="~/#link" runat="server" title=" <%$ Resources: myRess1 %>">
        <asp:Literal runat="server" Text="<%$ Resources: myRess1 %>" /><br />
        <img class="myClass2" src="/MasterPage/images/myGif.gif" width="19"  height="12" alt="" />
    </a>
</div>

when I browse a page that using this master page, the code become

<div class="myClass1">
    <a href="#link#link" title="myTitle">
        myTitle<br />
        <img class="myClass2" src="/MasterPage/images/.gif" width="19" height="12" alt="" /><br />
    </a>
</div>

why does the link double itself?

if I put something like default.aspx instead of #link, it work perfectly.

The reason why I'm using "~/" is because the master page is located somewhere else, if I don't put ~/ it make the link as /masterpage/#link which is invalid

+1  A: 

'~' can be used only with server controls and not with html controls. You should just use href="#link".

Neil
I'm pretty sure the '`~`' *can* be used if you put a `runat="server"` attribute in the HTML control's attributes.
Dan Herbert
the master page is located somewhere else, if I don't put ~/ it make the link as /masterpage/#link which is invalid
Fredou
Use something like /Test/TestAnchoreLinks.aspx#test
Neil
+2  A: 

The ~/ should not be necessary. Just use #link

Chris Ballance
the master page is located somewhere else, if I don't put ~/ it make the link as /masterpage/#link which is invalid
Fredou
A: 

for now I changed my

<a href="~/#link" runat="server" title=" <%$ Resources: myRess1 %>">

to

<a href="#link" title="<%=GetLocalResourceObject("myRess1 ") %>">

and it's working fine but if someone could tell me why with runat="server" screw up the #link, that would be good to know

Fredou