Getting error while disabling the text boxes on Web Form

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" Then

         control.GetType.GetTypeArray(control).CopyTo(temptxtbox, 0)

         For i = 0 To UBound(temptxtbox)

         temptxtbox(i).Enabled = True

         Response.Write(temptxtbox.ID)

      Next

   End If

disableAllTextBoxes(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
JigsDotNet
8/29/2005 7:31:21 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
1075 Views

Similar Articles

[PageSpeed] 9

You can cast it this way:

temptxtbox = CType(control, TextBox)

and then do:

temptxtbox.Enabled = False


LKZ:
.\Arrobianos/.
http://www.lukiller.net
0
LuKiller
8/29/2005 11:09:00 AM
Thx alot buddy////
it works.....
JIgnesh
0
JigsDotNet
8/29/2005 1:00:19 PM
Reply:

Web resources about - Getting error while disabling the text boxes on Web Form - asp.net.web-forms

Facebook Apologizes For Disabling Apps, Launches New Feedback Metrics, Granular Enforcement, Disabled ...
Facebook today apologized for suddenly disabling certain apps last month, saying that it “over-weighted certain types of user feedback, causing ...

Apple's wireless phone disabling patent - YouTube
Follow me on twitter at http://twitter.com/timcast Facebook - http://bit.ly/timpool In late August an Apple patent was published outlining technology ...

Disabling perceptions
All band movies are the same but different, especially this one, writes Craig Mathieson.

Heartbleed bug prompts disabling of public federal government sites
All federal departments using software vulnerable to the so-called Heartbleed bug have been ordered to immediately disable public websites.

Heartbleed bug prompts disabling of federal government public websites - CTV News
The federal tax agency says it expects to have its online services running again this weekend after blocking public access on April 9 due to ...

Heartbleed Bug Prompts Disabling Of Federal Government Public Websites
OTTAWA - The federal tax agency says it expects to have its online services running again this weekend after blocking public access on April ...

Home Depot confirms plans to accept Apple Pay soon after disabling it
... to find more special coverage of Apps and iOS . What do you think? Discuss "Home Depot confirms plans to accept Apple Pay soon after disabling ...

Retailers disabling NFC payments in preparation for new wireless payment method
Google Wallet never really gained popularity. It was fun paying for things by tapping your phone to a sensor, but not enough people knew about ...

Keychain app, Disabling screenshot sound [From the Forums]
From the Forums Just in case you missed out on some of the Android news today, now is the time to go ahead and get yourself fully caught up. ...

MX Player Updated With Android 5.0 Support, File Viewing Options, Easy Audio Track Disabling, And More ...
MX Player is now ready for Android Lollipop. No, it's not any prettier than it was before. There's no Material Design to drool over, no bright ...

Resources last updated: 1/16/2016 4:18:16 PM