Search code examples
htmlasp.netweb-controls

How to override the Render method?


I'm looking at a control that must output raw HTML and provide rich design-time support.

How to create a custom server control, extend the WebControl class and override the Render method?

Can you provide an example?

regards, Blanco


Solution

  • This will create a control that extends web control and overrides the Render method (though doesn't actually do anything with it.

    public class TestControl : System.Web.UI.WebControls.WebControl
    {
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            base.Render(writer);
        }
    }
    

    As you can see this is a fairly trivial answer but complete so I suspect that you didn't actually ask the question that you intended to.