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)
-   -   Adding Constituent Controls (http://p2p.wrox.com/showthread.php?t=35901)

AGS December 7th, 2005 06:39 PM

Adding Constituent Controls
Let me present some notes concerning section Creating a Complete Custom Control/Adding Constituent Controls of Chapter 3. I think there are some minor misprints and omissions which can confuse unaware reader. Sorry if I am wrong.

Second paragraph on page 77 states:

quote:Another way to ensure that your constituent controls have unique names is to not set the Id property for
your constituent controls. If you don’t set the Id property then unique values are automatically generated
for the name and id attributes of your constituent controls when your custom control is added to the page.
However, these values are essentially random values, affected by what other controls on the page are also
assigned automatic identifiers.
But if you don’t set Id property for constituent control its id attribute will not be rendered as opposed to name attribute and will not be available for client side code.

Another paragraph on page 77:

quote:You can retrieve the unique identifier that’s assigned to a control after the control has been added to the
Controls collection. You can then use that identifier when generating client-side code. This Visual Basic
2005 code retrieves the unique client-side identifier for a control:
And further there is an example of retrieving UniqueID property.
First: it is ClientID property that can be used for client-side code not UniqueID (though internally UniqueID is used to get ClientID but format still differs). There is another sentence on page 76 that in my opinion indirectly erroneously states that id attribute for HTML control will be taken from UniqueID property:

quote:At run time, when the HTML for your control is generated, the unique identifier for your control’s
client-side HTML is retrieved by reading your control’s UniqueId property.
Second – code example in VB and C# shows that instance of button is created and a variable is set to this button’s UniqueID property value. But control is not added to Controls collection so its UniqueID is null (or Nothing for VB). So the example seems to use a negative proof method of explanation if it was intentionally.
Third and the last – name of property is UniqueID not UniqueId and whereas it is valid for VB, C# variant of the example won’t compile.

Page 76. Last code block.
Misprint: C# variant of overridden property UniqueID has parentheses after property name.

Next to last code block on page 74 and first code block on page 77 have spaces inside name and id attributes values whereas they should literally reproduce HTML generated code.

Second code block on page 77 introduce an example of HTML generated by two instances of BookDetail control which contains buttons “Submit” and “Reset” (value attributes). But the second instance of the control has value attribute set to “on click” for both buttons. As it is supposed that we are generating this control completely in code it is unlikely that it was done intentionally.

Third paragraph on page 75 contains sentence:

quote:If the control is in a Panel on a user control, all three properties
point to different objects: the Page property points to the Page object, the Panel property points to the
Panel, and the NamingContainer points to the user control.
Misprint: Panel property points to the Panelinstead of Parent property points to the Panel.

Once again sorry if I am wrong. Actually I think the book is great. Thank you.

Best regards

peter.vogel@phvis.com December 12th, 2005 06:32 AM

You're right, of course. I must have had a brain cramp when I put UniqueID instead of ClientID in this chapter (I got the distinction right when the topic comes up again in chapter 9 where I actually do discuss working with client-side code). The distinction is nefarious because (I think) UniqueID will look like it's working as long as the control isn't nested inside any other control but will fail when the control is nested because of the separator used between control names in the UniqueID. My apologies.

We'll also correct the other misprints you found in the next edition <sigh>.

I really appreciate you taking the time to work through the book in this detail. Will you be giving the same keen eye to later chapters? (I'd certainly appreciate it).

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 06:22 AM.

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