Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing Controls
Message
De
04/02/2003 15:49:31
Rex Mahel
Realm Software, Llc
Ohio, États-Unis
 
 
À
04/02/2003 15:18:03
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00749032
Message ID:
00749057
Vues:
35
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform