How can I force the WebControl
to render as a <div>
? Currently, it renders as a <span>
and our UI guy prefers it be a <div>
. To accommodate him, I'd like to see if this is possible and if so, how it's possible.
You can override the RenderBeginTag method of WebControl:
public override void RenderBeginTag(HtmlTextWriter writer)
{
writer.RenderBeginTag("div");
}
There's also a RenderEndTag that you can override, which might not be necessary in this case:
public override void RenderEndTag(HtmlTextWriter writer)
{
writer.RenderBeginTag();
}
Yes, it is definitely possible. Asp.net gives you full control over the output rendered.
Take a look at Control Adapters
The asp.net team has released many adapters for CSS friendly rendering for controls like Menu, TreeView, and FormView. Take a look at CSS friend control adapters
You can always build your own to customize the rendering as needed by your UI guy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With