Groups | Blog | Home
all groups > asp.net > april 2006 >

asp.net : Iterate through page controls


Nathan Sokalski
4/23/2006 8:08:38 PM
I would use an If statement inside the loop to check the type. For example,
try putting this If statement inside the For loop:


If t.GetType().ToString()="System.Web.UI.WebControls.TextBox" Then

End If


Then put any code you want inside the If statement so that the code will
only be executed on TextBox Controls. Good Luck!
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

[quoted text, click to view]

Avon
4/23/2006 10:33:06 PM
Hi friends,

I need of some help,

I have this code:



For Each t As TextBox In Page.Controls ' here is the error



t.Text = "test"

Next



But I am getting this error:

Unable to cast object of type 'ASP.masterpages_maindesign_master' to type
'System.Web.UI.WebControls.TextBox'.





Please help me to understand this error and solve the problem

Thanks in advance

AddThis Social Bookmark Button