I found these instructions here in the stack overflow somewhere ... I only added the last loop to find the only objects that interest me i.e. textbox and dropdownlist ... For found objects I need to change the ReadOnly property from true to false or vice versa ... I'm not able to identify how to I can define the object name of the affected objects ...
Thanks in advance for your help.
foreach (Control ctlMaster in Page.Controls)
{
if (ctlMaster is MasterPage)
{
foreach (Control ctlForm in ctlMaster.Controls)
{
if (ctlForm is HtmlForm)
{
foreach (Control ctlContent in ctlForm.Controls)
{
if (ctlContent is ContentPlaceHolder)
{
foreach (Control ctlChild in ctlContent.Controls)
{
if (ctlChild is Panel)
{
foreach (Control ctlform in ctlChild.Controls)
{
if (!string.IsNullOrEmpty(ctlform.ID))
{
Debug.WriteLine("ID = [" + ctlform.ID + "]");
Debug.WriteLine("UniqueID = [" + ctlform.UniqueID + "]");
Debug.WriteLine("type = [" + ctlform.GetType() + "]");
if(ctlform.GetType().ToString().IndexOf("TextBox") != 0
|| ctlform.GetType().ToString().IndexOf("DropDownList") != 0)
{
// **??? objectName.ReadOnly = true; ???**
}
}
}
}
}
}
}
}
}
}
}