Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing Controls
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00749032
Message ID:
00749071
Views:
24
The Feb. Issue of the UT Magazine has a tip about how to iterate through all the controls on the ASP.NET page. Here is the link to the Feb. Issue. Click on the picture of the magazine and then click on "Cathi Gero's .NET Tips". The tip is the one on the lower left:

http://www.levelextreme.com/Magazine/


>Hi I have a web form that contains numerous text boxes and dropdown boxes that have repetitive names such as:
>Drop1,drop2,drop3,etc
>text1,text2,text3,etc.
>
>I am trying to reference said controls in a loop rather than 6 seperate procedures for example:
>
>dim Cl as dropdownlist
>For i = 1 to 6
> Cl.ID = "Drop" & i
> If CL.SelectedIndex > 0 Then
> If Text1.Text <> "" Then
> Some Code Here
> End If
> If Text2.Text <> "" Then
> Some Code Here
> End If
> End If
>Next
>This gives me the error:
>Cast from type 'DropDownList' to type 'String' is not valid.
>
>Is there a way to reference controls like this? If so, How?
>
>Thanks in advance
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Reply
Map
View

Click here to load this message in the networking platform