Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing Controls
Message
From
04/02/2003 15:49:31
Rex Mahel
Realm Software, Llc
Ohio, United States
 
 
To
04/02/2003 15:18:03
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00749032
Message ID:
00749057
Views:
34
Mike,

Try this:
	For i = 1 to 6
		strTextBoxName = "txtBox" & CStr(i)
		txtBox = CType(FindControl(strTextBoxName),TextBox)
		If txtBox.Text >? "" Then
			Some Code Here
		End If
	End For
HTH

Rex


>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform