Alek Jox

Alek Jox

  • NA
  • 1
  • 0

RenderControl and Render methods

Aug 23 2006 10:37 AM

If i use following code
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw);
this.Render(writer);
string sHtml = sw.ToString();
Content of sHtml is same as if I used following code
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw);
this.RenderControl(writer);
string sHtml = sw.ToString();
In first case i get an error
[b]System.Web.HttpException: A page can have only one server-side Form tag[/b].
What is the difference? Do Render method uses writer of Response object no matter what is put as input writer? In that case rendering of page would happen twice?
p.s
in this.RenderControl and this.Render "this" is Page object