J
Jiho Han
In CreateChildControls method of my Page, I am trying to see if a hidden
input field is present (by id) and if not, add it to a predefined form (by
id).
protected override void CreateChildControls()
{
base.CreateChildControls();
HtmlForm form = FindControl("myForm") as HtmlForm;
HtmlInputHidden hiddenField = form.FindControl("hiddenId") as
HtmlInputHidden;
if (hiddenField == null)
{
hiddenField = new HtmlInputHidden();
hiddenField.Id = "hiddenId";
form.Controls.Add(hiddenField);
}
// Controls.Add(hiddenField);
}
Now if I uncomment the last Controls.Add line, it will add the hidden field
to the page outside of the form which is not what I want.
Can someone point me out?
Thanks.
input field is present (by id) and if not, add it to a predefined form (by
id).
protected override void CreateChildControls()
{
base.CreateChildControls();
HtmlForm form = FindControl("myForm") as HtmlForm;
HtmlInputHidden hiddenField = form.FindControl("hiddenId") as
HtmlInputHidden;
if (hiddenField == null)
{
hiddenField = new HtmlInputHidden();
hiddenField.Id = "hiddenId";
form.Controls.Add(hiddenField);
}
// Controls.Add(hiddenField);
}
Now if I uncomment the last Controls.Add line, it will add the hidden field
to the page outside of the form which is not what I want.
Can someone point me out?
Thanks.