only My site

Wednesday, November 14, 2007

Altering the page using Render

Hi

I had a chat with collegues and we discovered some interesting and useful stuff in the Render method.

I added a button and link button server controls and i like to remove the submit button from the page at runtime (to test the render feature).

protected override void Render(HtmlTextWriter output)
{

System.IO.StringWriter writer = new System.IO.StringWriter();
HtmlTextWriter buffer = new HtmlTextWriter(writer);
base.Render(buffer);
string sGridHtml = writer.ToString();
string strRemove = "HTML STATEMENT FOR BUTTON CONTROL";
sGridHtml = sGridHtml.Replace(strRemove, "");
output.Write(sGridHtml);
return;


}

No comments: