How to get Collection of Controls on a WebForm
Hi Mark,
From my understanding, the server controls are not in the Page.ControlCollection (this.Controls), but in the HtmlForm.ControlControlCollection. I guess this is why the
control IDs were not able to retrieved.
Regards,
Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Quote:
>Content-Class: urn:content-classes:message
>Subject: How to get Collection of Controls on a WebForm
>Date: Wed, 5 Jun 2002 06:56:20 -0700
>Lines: 18
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Thread-Index: AcIMmMWerR2AzCYmQoaUx/Nu1zBDjg==
>Newsgroups: microsoft.public.dotnet.languages.
CSharp >NNTP-Posting-Host: TKMSFTNGXA14 10.201.226.42
>Path: cpmsftngxa07!cpmsftngxa06!cpmsftngxa08
>Xref: cpmsftngxa07 microsoft.public.dotnet.languages.csharp:65955
>X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
>Hello
> My form has 10 Checkbox Lists, 10 DropDownLists and 20
>labels.
>I need to get the ID and Type for type. I'll load the ID
>into a ListBox. I have the following, but it does not
>seem work. Any Ideas are greatly appreciated.
>foreach(Control control in this.Controls)
>{
> string id = control.ID;
> lb1.Items.Add(id);
>}
>Thanks Mark