Prevent wrapping tags for ASP.NET server control

asp.netservercontrols

I am writing various ASP.NET Server controls and am needing to remove the tags that wrap my control by default. I am aware that you can change the tag to a different tag (as in this question, How Do I Change the render behavior of my custom control from being a span) but how can you prevent it?

I am inheriting from WebControl (can also inherit from CompositeControl).

I typically get:

<span>Control output</span>

I need:

Control output

I am overriding RenderContents(HtmlTextWriter output) and the CreateChildControls() methods (across various controls). My immediate need is to address the issue using the RenderContents(HtmlTextWriter output) method.

Best Answer

What about this?

    public override void RenderBeginTag(HtmlTextWriter writer)
    {
        writer.Write("");
    }

    public override void RenderEndTag(HtmlTextWriter writer)
    {
        writer.Write("");
    }