Is there a way to change multiple readonly textbox attributes programmatically
5 answers
Assuming your textboxes start with the same prefix and exist in the page controls collection:
string commonTextBoxPrefix = "txt";
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(TextBox) &&
c.Name.StartsWith(commonTextBoxPrefix))
{
((TextBox)c).ReadOnly = True;
}
}
This won't return the entire control hierarchy, though :)
+2
source to share