Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2008, 09:20 AM
Authorized User
 
Join Date: Jun 2008
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
 
Old June 24th, 2008, 04:24 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
 
Old June 25th, 2008, 08:02 AM
Authorized User
 
Join Date: Jun 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, Imar. That makes sense. Cheers, Roman.
 
Old June 25th, 2008, 08:31 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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
 
Old June 25th, 2008, 05:01 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.





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





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