I have an "ascx" referenced inside an aspx page.
I was using the following in the aspx page to reset certail controls to "". It worked fine, but when i decided to refactor and moved it into the referenced ascx page it stopped working. I tried adding another depth to it but I can't seem to find the correct term.
thanks for your time.
I was using the following in the aspx page to reset certail controls to "". It worked fine, but when i decided to refactor and moved it into the referenced ascx page it stopped working. I tried adding another depth to it but I can't seem to find the correct term.
Code:
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 TextBox)
{
if (!string.IsNullOrEmpty(ctlChild.ID))
{
TextBox t = (TextBox)ctlContent.FindControl(ctlChild.ID);
t.Text = "";
}
}
if (ctlChild is Label && ctlChild.ID != null)
{
Label l = (Label)ctlContent.FindControl(ctlChild.ID);
l.Text = "";
}
}
}
}
}
}
}
}
thanks for your time.