johnny
johnny

Reputation: 1251

ASP.NET Webforms write output html for control

I want to create my own hierarchical navigation menu control without using standart ASP.NET controls. So, I want to control my html output and I found out that I can override Render method to write html into respose. Is it good place for this? Where in control creating lifecycle I should prepare data for my control?

protected override void Render(HtmlTextWriter writer)
{
    base.Render(writer);
    Response.Write("<b>hello</b>");
}

Upvotes: 0

Views: 1618

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039508

It is exactly the Render method that is the correct place to do this. But don't write it to the Response, write it to the provided as argument HtmlTextWriter instead.

Upvotes: 2

Related Questions