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

后端 未结 10 1553
轻奢々
轻奢々 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:35

    I had a similar issue when rendering the page with PageParser.GetCompiledPageInstance() or when the url was rewritten. For some reason the HtmlAnchor always resolved incorrectly (similar to what you have above).

    Ended up just using a HtmlGenericControl, since you are manipulating it server-side anyway this may be a possibility for you.

    HtmlGenericControl anchor = new HtmlGenericControl("a");
    anchor.Attributes.Add("href", "#");
    

提交回复
热议问题