Hello,
We have some code which is designed to build up a key/value pair of controls on a ASP.NET webforms page and their values. We use the "Controls" collection and recursion to build up this key/value pair.
The only issue is that ascx controls don't appear to come back in the "Controls" collection. Instead we get the controls on the ascx.
Something similar to the following code:
protected override void OnLoad(EventArgs e)
{
GetControls(this);
}
protected void GetControls(System.Web.UI.Control ctl)
{
foreach (Control subCtl in ctl.Controls)
{
GetControls(subCtl);
string value;
if (GetValueFromControl(subCtl, out value))
{
_ControlValues.Add(subCtl.ClientID, value);
}
}
}
The subCtl is never a ascx control. Is there a way to get a list of the ascx controls on page or better still a different collection that contains both types?
Thanks
Hans