H
heybrakywacky
After hours of pulling my hair out on this one, I've finally realized
that the problem I'm having in my code is due to behavior that is not
at all expected.
Using ASP.NET 1.1.4322.2032, I'm trying to update a dynamically-created
hidden control on my form, across multiple postings. My experience
suggests that once the initial version of the hidden control has been
created and populated, there is no changing that value in subsequent
post-backs. The following code illustrates this issue:
--- Code Behind ---
....
private void Page_Load(object sender, System.EventArgs e)
{
if (this.IsPostBack)
{
int hiddenVal = int.Parse(Request.Form["hiddenControl_1"]);
hiddenVal++;
HtmlInputHidden hiddenControl = new HtmlInputHidden();
hiddenControl.ID = hiddenControl.Name = "hiddenControl_1";
hiddenControl.Value = hiddenVal.ToString();
Control formControl = this.FindControl("HiddenValueUpdateForm");
formControl.Controls.Add(hiddenControl);
}
else
{
HtmlInputHidden hiddenControl = new HtmlInputHidden();
hiddenControl.ID = hiddenControl.Name = "hiddenControl_1";
hiddenControl.Value = "1";
Control formControl = this.FindControl("HiddenValueUpdateForm");
formControl.Controls.Add(hiddenControl);
}
}
....
--- Code Behind ---
--- Web Page ---
....
<body MS_POSITIONING="GridLayout">
<form id="HiddenValueUpdateForm" name="HiddenValueUpdateForm"
method="post" runat="server">
<input type="submit" runat="server" id="btnSubmit"
name="btnSubmit" value="Submit Query">
</form>
</body>
....
--- Web Page ---
You can see from the code that the expected behavior is that the hidden
field is dynamically initialized and added to the form controls on the
first visit to the page. Then the value is incremented on post-back,
then added back to the form controls.
The actual behavior is that while the control is added to the page each
time, the value is never updated past its initialization value ("1").
Is this a bug, or is there some rational explanation for this behavior?
It's certainly not the behavior I expect.
Thanks,
Kevin
that the problem I'm having in my code is due to behavior that is not
at all expected.
Using ASP.NET 1.1.4322.2032, I'm trying to update a dynamically-created
hidden control on my form, across multiple postings. My experience
suggests that once the initial version of the hidden control has been
created and populated, there is no changing that value in subsequent
post-backs. The following code illustrates this issue:
--- Code Behind ---
....
private void Page_Load(object sender, System.EventArgs e)
{
if (this.IsPostBack)
{
int hiddenVal = int.Parse(Request.Form["hiddenControl_1"]);
hiddenVal++;
HtmlInputHidden hiddenControl = new HtmlInputHidden();
hiddenControl.ID = hiddenControl.Name = "hiddenControl_1";
hiddenControl.Value = hiddenVal.ToString();
Control formControl = this.FindControl("HiddenValueUpdateForm");
formControl.Controls.Add(hiddenControl);
}
else
{
HtmlInputHidden hiddenControl = new HtmlInputHidden();
hiddenControl.ID = hiddenControl.Name = "hiddenControl_1";
hiddenControl.Value = "1";
Control formControl = this.FindControl("HiddenValueUpdateForm");
formControl.Controls.Add(hiddenControl);
}
}
....
--- Code Behind ---
--- Web Page ---
....
<body MS_POSITIONING="GridLayout">
<form id="HiddenValueUpdateForm" name="HiddenValueUpdateForm"
method="post" runat="server">
<input type="submit" runat="server" id="btnSubmit"
name="btnSubmit" value="Submit Query">
</form>
</body>
....
--- Web Page ---
You can see from the code that the expected behavior is that the hidden
field is dynamically initialized and added to the form controls on the
first visit to the page. Then the value is incremented on post-back,
then added back to the form controls.
The actual behavior is that while the control is added to the page each
time, the value is never updated past its initialization value ("1").
Is this a bug, or is there some rational explanation for this behavior?
It's certainly not the behavior I expect.
Thanks,
Kevin