p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X (http://p2p.wrox.com/forumdisplay.php?f=225)
-   -   Combining Controls and HTML (http://p2p.wrox.com/showthread.php?t=36049)

AGS December 12th, 2005 06:05 PM

Combining Controls and HTML

First, some minor notes:

Page 27. First paragraph in italics references property EmptyZoneText
as EmptyPartText.

Throughout the book (pages 80, 82, 83, 84, 86, 88 and so on) name of type HtmlTextWriter is written as HTMLTextWriter (and enumeration HtmlTextWriterTag as HTMLTextWriterTag). I think it is better to use correct name. And on page 276 (last code block) C# variant of Render() method has type of parameter HTMLTextWriter instead of HtmlTextWriter which causes compilation error.

Pages 82 (second code block) and 83 (first code block):
Misprint: C# variants of Render() method contain “&” characters as concatenation operator instead of “+” (<img/> element generation).

Page 85. Last paragraph:
Property ChildControlsCreated referenced as ChildControlsRendered and method CreateChildControls() as

And now more involved question:
Page 85. Section Combining Controls and HTML
First paragraph states:

quote:It is possible to break your text generation down into finer parts by overriding the custom control’s other
Render* methods. These methods are automatically run by the base Render method in the WebControl
As far as I understand it means that Render* methods (which were previously defined as Render, RenderControl, RenderChildren) other than Render (i.e. RenderControl and RenderChildren) are called by Render method. And Figure 3.8 has Render method at the root of the tree structure. But I think if we are talking about WebControl class it is not true. RenderControl is public while Render is protected and it is RenderControl method that allows a class that consumes the control to render it. And RenderControl is not run by Render method. Quite the opposite.

WebControl.RenderContents method calls Control.Render method which in turn calls Control.RenderChildren. It is where (or more precisely in RenderChildrenInternal in .NET Framework 2.0) we have RenderControl method called to render child controls of our control. And if we are talking about containing control for our current WebControl so it is RenderControl method which is called to render it and it is RenderControl which should be at the root of the tree structure.

And further on page 88 there is a paragraph:

quote:The RenderBeginTag, RenderContents, and RenderEndTag methods are not called

directly from the Render method. Instead, they are called from the RenderControl
method, which is called from the Render method. So, in order to use these methods
you must not override either the Render or RenderControl methods.
But RenderBeginTag, RenderContents, and RenderEndTag are called from WebControl.Render method, not from RenderControl. And once again Control.RenderControl is not called from the Control.Render method.

Sorry if I am wrong.

Best regards,

peter.vogel@phvis.com January 15th, 2006 06:19 PM

First: My apologies for taking so long to respond. I thought that I had subscribed to this forum so that I would get all the new postings--I was obviously mistaken.

Second: thanks for catching all the typos--especially the caps on HtmlTextWriter. That's the kind of thing that can drag on through a book's history.

On the Render methods: You're right. I've got Render and RenderControl swapped around in the diagram and through this section <sigh>. The top of the heap is definitely the RenderControl method (I slapped together a test just now in the faint hope that I had gotten it right back in the book and you were wrong--no luck).

When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.

- Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"

All times are GMT -4. The time now is 11:05 PM.

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