T
TWEB
Hi there,
I'm using VS2003.
I have a hidden control:
<input id="hdnABC" type="hidden" runat="server" value="-1">
This control is defined on my codebehind class as:
protected System.Web.UI.HtmlControls.HtmlInputHidden hdnABC;
This hidden element is manipulated by Javascript on the client. For the
purpose of this discussion, let's say the Javascript changes the element
value from -1 to 1.
<script type="text/javascript">
document.getElementbyid("hdnABC").value = 1;
</script>
I have a "Save" button which does a postback:
<asp:button id="btnSave" runat="server" Text="Save"></asp:button>
private void btnSave_Click(object sender, System.EventArgs e)
{
saveABC();
}
When I click Save button from the client, I'm having trouble with
referencing the hidden form element.
Referencing the server control in this fashion:
int foo = System.Convert.ToInt32(hdnABC.Value);
yields a different result than:
int bar = System.Convert.ToInt32(Request.Form.Get("hdnABC"));
Variable "foo" yields "-1" (INCORRECT)
Variable "bar" yields "1" (CORRECT)
Why is it that hdnABC.Value isn't in sync with Request.Form.Get("hdnABC")???
Please post replies directly to newsgroup.
Thanks
I'm using VS2003.
I have a hidden control:
<input id="hdnABC" type="hidden" runat="server" value="-1">
This control is defined on my codebehind class as:
protected System.Web.UI.HtmlControls.HtmlInputHidden hdnABC;
This hidden element is manipulated by Javascript on the client. For the
purpose of this discussion, let's say the Javascript changes the element
value from -1 to 1.
<script type="text/javascript">
document.getElementbyid("hdnABC").value = 1;
</script>
I have a "Save" button which does a postback:
<asp:button id="btnSave" runat="server" Text="Save"></asp:button>
private void btnSave_Click(object sender, System.EventArgs e)
{
saveABC();
}
When I click Save button from the client, I'm having trouble with
referencing the hidden form element.
Referencing the server control in this fashion:
int foo = System.Convert.ToInt32(hdnABC.Value);
yields a different result than:
int bar = System.Convert.ToInt32(Request.Form.Get("hdnABC"));
Variable "foo" yields "-1" (INCORRECT)
Variable "bar" yields "1" (CORRECT)
Why is it that hdnABC.Value isn't in sync with Request.Form.Get("hdnABC")???
Please post replies directly to newsgroup.
Thanks