I'm using ascx and I need to iterate through all of the controls and selects each that have cssClass attribute set to 'required'.
I have the following code:
foreach (Control masterControl in Page.Controls)
{
if (masterControl is MasterPage)
{
foreach (Control formControl in masterControl.Controls)
{
if (formControl is System.Web.UI.HtmlControls.HtmlForm)
{
foreach (Control contentControl in formControl.Controls)
{
if (contentControl is ContentPlaceHolder)
{
foreach (Control childControl in contentControl.Controls)
{
}
}
}
}
}
}
}
however.. i cannot access childControl.CssClass. How do I access it?
Thanks in advance!