Enable all textboxes

G

Guest

i have an aspx form containing several textboxes.Is there a
way with a for loop or something to enable or disable the textboxes, instead
of
writing textboxName.enable


i appriciate any help i need that method
waiting for a quick response
Thanks a lot
 
G

Grant Merwitz

something like:

foreach(Control c in Controls)
{
if(c is TextBox)
{
c.Enabled = false;
}
}
 
K

Karl Seguin

You'll probably need to deal with nested textboxes, so you'll need to make
it recursive.

public sub EnableAllTextBoxes(parent as Control, enabled as Boolean)
foreach child as Control in parent.Controls
if child.HasControls then
EnableAllTextBoxes(child, enabled )
end if
if c is TextBox then 'forgot how to do this in vb.net ?? typeof c is
TextBox ??
c.Enabled = enabled
end if
end sub

karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top