Tom Knowlton
asked on
Loop through all controls in a user control
How do I properly recurse all of the controls in a User Control (.ascx)?
here is my attempt:
My intent is to loop through all the controls and make the textbox controls read only.
here is my attempt:
private Control FindNestedControl(ControlCollection c, string typeasstring, bool value)
{
Control tempControl = null;
foreach (Control cc in c)
{
string contype = cc.GetType().ToString();
if (contype == typeasstring)
{
((System.Web.UI.WebControls.TextBox)cc).BorderWidth = 0;
((System.Web.UI.WebControls.TextBox)cc).ReadOnly = value;
((System.Web.UI.WebControls.TextBox)cc).Enabled = !value;
tempControl = FindNestedControl(cc.Controls, typeasstring, value);
}
}
return tempControl;
}
My intent is to loop through all the controls and make the textbox controls read only.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER