Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 23rd, 2006, 10:19 AM
Authorized User
Points: 202, Level: 4
Points: 202, Level: 4 Points: 202, Level: 4 Points: 202, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
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
  #2 (permalink)  
Old August 23rd, 2006, 11:03 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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."
  #3 (permalink)  
Old August 24th, 2006, 03:41 AM
Authorized User
Points: 202, Level: 4
Points: 202, Level: 4 Points: 202, Level: 4 Points: 202, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
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?

  #4 (permalink)  
Old August 24th, 2006, 08:36 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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."
  #5 (permalink)  
Old August 24th, 2006, 09:10 AM
Authorized User
Points: 202, Level: 4
Points: 202, Level: 4 Points: 202, Level: 4 Points: 202, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
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.

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
using Page.RenderControl() net_hunk .NET Framework 2.0 2 May 26th, 2014 05:26 AM
Zoom in the render Tepox2000 Reporting Services 0 October 24th, 2006 01: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 10:21 AM
Render to Printer kirbykn BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 April 21st, 2005 04:17 PM



All times are GMT -4. The time now is 09:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.