Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2006, 09:19 AM
Authorized User
 
Join Date: Nov 2005
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default RenderControl and Render methods

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
System.Web.HttpException: A page can have only one server-side Form tag.
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
 
Old August 23rd, 2006, 10:03 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

RenderControl is used to place items on the page that are created dynamically and, I *think*, when you call this.Render() you are recalling the pages render method which would also recreate all of the controls on the page.

(Hence Render is called before you explicitly call this.Render() which means a <form runat=server> tag has already been placed on the page then, when you call this.Render(), it places another form tag on the page.)

HTH.

"The one language all programmers understand is profanity."
 
Old August 24th, 2006, 02:41 AM
Authorized User
 
Join Date: Nov 2005
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default

yes this.Render will render all controls but I put this.Render(writer); where "writer" object has been just created ,then how is it (my writer)connected within Response's output stream?

 
Old August 24th, 2006, 07:36 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I assume that writer contains some control that you are trying to dynamically output to the page, in which case you want to use RenderControl.

If you want a more in depth explination go here and also check out the links to the MSDN. http://www.velocityreviews.com/forum...ercontrol.html

"The one language all programmers understand is profanity."
 
Old August 24th, 2006, 08:10 AM
Authorized User
 
Join Date: Nov 2005
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default

Thanks for help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
using Page.RenderControl() net_hunk .NET Framework 2.0 2 May 26th, 2014 04:26 AM
Zoom in the render Tepox2000 Reporting Services 0 October 24th, 2006 12:19 PM
How to catch exceptions in Render methods? jacob ASP.NET 1.0 and 1.1 Professional 1 November 17th, 2005 06:21 PM
Using rendercontrol with parameters? shenku C# 2 October 13th, 2005 09:21 AM
Render to Printer kirbykn BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 April 21st, 2005 03:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.