Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X
This is the forum to discuss the Wrox book Professional Web Parts and Custom Controls with ASP.NET 2.0 by Peter Vogel; ISBN: 9780764578601
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 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 Search this Thread Display Modes
  #1 (permalink)  
Old December 7th, 2005, 06:39 PM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Alexey Gorkov
  #2 (permalink)  
Old December 12th, 2005, 06:32 AM
Authorized User
Join Date: Dec 2005
Location: Goderich, Ontario, Canada.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts

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"

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Adding controls to a form Scootterp Access VBA 2 August 4th, 2009 02:32 PM
Adding Controls Dynamically andyj00 C# 0 March 19th, 2007 08:54 AM
Adding controls dynamicly Paula222 Access VBA 21 February 9th, 2006 05:29 AM
binding a constituent control to property ParadiseIsle Beginning VB 6 1 November 11th, 2005 02:08 PM
Adding controls to C# clojinted General .NET 1 February 12th, 2005 03:17 PM

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

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