Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 24th, 2008, 09:20 AM
Authorized User
 
Join Date: Jun 2008
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Uniqueness of LoginStatus controls

Hi Imar,

In the code on page 548, there are two LoginStatus controls with the same ID. I have tried the code and did not get any error messages. Is it generally OK to have multiple LoginStatus controls with the same ID in the same file? If so, are there any other controls for which it would be OK too? Does the requirement for the uniqueness of IDs on a page only apply to HTML elements?

Thank you for your trouble.

Roman
Reply With Quote
  #2 (permalink)  
Old June 24th, 2008, 04:24 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Roman,

Control IDs must be unique within their "naming container". Normally, the Page is the default container, so within each page the controls must have unique IDs.

The code on page 548 shows a LoginView control with different templates that define new naming containers. Since only one template can be active at any time, you can reuse the control IDs. When logged in you get LoginStatus1 from the RoleGroups element, otherwise you get the one from the LoggedInTemplate.

Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old June 25th, 2008, 08:02 AM
Authorized User
 
Join Date: Jun 2008
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, Imar. That makes sense. Cheers, Roman.
Reply With Quote
  #4 (permalink)  
Old June 25th, 2008, 08:31 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Imar,

I started to write a response very similar to yours but then wasn't sure if I was right. Aren't all controls that can contain other controls naming containers? Are the templates of templated controls naming containers as well? I have used the same technique you demonstrate several times without problems.

-Peter
compiledthoughts.com
Reply With Quote
  #5 (permalink)  
Old June 25th, 2008, 05:01 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yes, AFAIK, all controls that can contain other controls are naming containers.

I am not 100% sure about templates. Maybe .NET internally knows only one of them can be active at any time and doesn't bother with IDs there.
The net effect is the same though: you can't use multiple controls within a container. ASP.NET must always be able to create unique controls like ParentId_FirstChildId_SecondChildId and so on.

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
Reply


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
column uniqueness that trim's trailing whitespace? callagga SQL Language 0 July 28th, 2008 09:45 PM
Need Help in LoginStatus and Asp:ImageButton [Mini kamii47 ASP.NET 2.0 Basics 0 September 1st, 2007 04:24 PM
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
Controls dparsons VB.NET 2002/2003 Basics 1 October 19th, 2005 11:08 AM



All times are GMT -4. The time now is 10:44 PM.


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