G
Guest
Hi everyone,
I'd like to interrogate a web form to check for values of the controls on
the form. The following codes worked when I execute it in a User Control that
has some web controls on it but I can't seem to get it to work directly on
the form itself.
using System.Web;
using System.Web.UI;
using System.Web.UI,WebControls;
foreach (Control ctrl in this.Controls)
{
if (ctrl is TextBox)
do something
else if (ctrl is DropDownList)
do something else
}
When the above code is done at the Page_Load() of the aspx file, the
this.Controls return System.Web.UI.LiteralControl, System.Web.UI.HTMLControls
etc in the Controls collection but not the Textboxes and other Web Controls.
Is this correct or have I done something wrong?
It'd be greatly appreciated if someone out there can enlighten me please.
KD
I'd like to interrogate a web form to check for values of the controls on
the form. The following codes worked when I execute it in a User Control that
has some web controls on it but I can't seem to get it to work directly on
the form itself.
using System.Web;
using System.Web.UI;
using System.Web.UI,WebControls;
foreach (Control ctrl in this.Controls)
{
if (ctrl is TextBox)
do something
else if (ctrl is DropDownList)
do something else
}
When the above code is done at the Page_Load() of the aspx file, the
this.Controls return System.Web.UI.LiteralControl, System.Web.UI.HTMLControls
etc in the Controls collection but not the Textboxes and other Web Controls.
Is this correct or have I done something wrong?
It'd be greatly appreciated if someone out there can enlighten me please.
KD