Ok, so what I got is 10 textboxes on a .Net page. What I need to do is loop through them in C# and change the ids. The code I have on the .cs page behind the .aspx page is as follows:
Problem is the code can only change certain properties of the textbox, right? Color, Value, etc. Also, the "foreach" conditional statement doesn't loop. Can someone provide a little help so I can loop through and change the ids?
Thanks
Code:
protected void Page_Load(object sender, EventArgs e)
{
LoopTextboxes(Page.Controls);
}
private void LoopTextboxes(ControlCollection controlCollection)
{
foreach (Control control in controlCollection)
{
if (control is TextBox)
{
((TextBox)control).Text = "Text Here";
}
if (control.Controls != null)
{
LoopTextboxes(control.Controls);
}
}
}
Thanks
Comment