I have an arraylist of asp.net controls (textbox, etc).
I need to check if a control exists in the arraylist already before adding a new one. How can I do this, since the .Contains doesn’t seem to work properly on the ArrayList of controls.
This is what I’m trying to do:
Private Sub AddControl(ByVal ctrl As Control)
Dim al As ArrayList = DirectCast(Session("MyControls"), ArrayList)
If Not al.Contains(ctrl) Then
al.Add(ctrl)
Session("MyControls") = al
End Sub
maybe this will work: