Hello Folks...
THis is very urgent ...Plz help...
Following is a piece of code....to disable all the textBoxes on a WebForm in ASP.Net.(Lang:VB.Net)
Private Sub disableAllTextBoxes(ByVal ControlArray) Dim control As Object Dim temptxtbox Dim i As Integer For Each control In ControlArray If control.GetType.Name = "TextBox" Thencontrol.GetType.GetTypeArray(control).CopyTo(temptxtbox, 0)
For i = 0 To UBound(temptxtbox)temptxtbox(i).Enabled =
TrueResponse.Write(temptxtbox.ID)
Next End IfdisableAllTextBoxes(control.Controls)
Next End Sub
The looping is perfect.It detects the System.Web.UI.WebControls.TextBox collection.
In the above code the red colored line is the place where i get the following error....
"System.InvalidCastException: Specified cast is not valid.
I m a beginner ....so regret if there is something silly in it.
Regards,
Jignesh
![]() |
0 |
![]() |
You can cast it this way:
temptxtbox = CType(control, TextBox)
and then do:
temptxtbox.Enabled = False
LKZ:
.\Arrobianos/.
http://www.lukiller.net
![]() |
0 |
![]() |
Thx alot buddy////
it works.....
JIgnesh
![]() |
0 |
![]() |