0
Answer

RenderControl and Render methods

Alek Jox

Alek Jox

18y
2.2k
1

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