How to remove span tag from WebControl when rendered

后端 未结 15 979
生来不讨喜
生来不讨喜 2020-12-31 03:34

When using an ASP.NET CheckBox (and in out case, inherited from a CheckBox) it renders a span around the checkbox input control, this span control

15条回答
  •  清酒与你
    2020-12-31 04:26

    I've found that by implementing a constructor like the one below, you can specify the container tag for your control.

    public MyCustomControl() : base(HtmlTextWriterTag.Div)
    {
    }
    

    You can replace the HtmlTextWriterTag with any of the aviable options, such as Div in the example above. The default is Span.

提交回复
热议问题