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

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

    What about this?

    HtmlAnchor errorLink = new HtmlAnchor();
    errorLink.InnerText = this.Message;
    errorLink.HRef = errorLink.ResolveClientUrl("#" + this.FormControlId);
    errorLink.Attributes["rel"] = "form_help";
    

    Works for me but I'm using a Server Control in a Class Library as opposed to a User Control. I think it should work for a User Control as well.

提交回复
热议问题