asp.net user control, getting htmlAnchor resolve to href=“#”

后端 未结 10 1525
轻奢々
轻奢々 2020-12-29 04:58

How do you get a server control HTMLAnchor to have href=\"#\". It keeps resolving the \"#\" to the control path.


res         


        
10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 05:34

    Brendan Kowitz solution will work, however i was not able to implement it due to the way this control is to operate. I ended up having to hack it as per the following code in the code behind:

    lnk.Attributes.Add("href",Page.Request.Url.ToString() + "#");
    

    Where lnk is an HtmlAnchor.

    The reason for this issue in the first place is the control is not in the same directory as the page, and .Net goes about "intelligently" fixing your problem for you. The above will work, though if anyone has a better solution i'm all ears.

提交回复
热议问题