Reputation: 1063
I programmatically created few hidden fields at client side, inserted into the form. I verified the form.childElementCount does increased.
var disabledState_id = "<%=HidData_DisabledState_Prefix%>" + uiObj.attr("id");
...
disabledState = $("<input type='hidden' id='" + disabledState_id + "' />");
disabledState.appendTo("form");
when postback, I can't find these hidden values in Request.Form . can't find those keys as well in Request.Form.AllKeys, as the id is fixed to a prefix.
Upvotes: 0
Views: 175
Reputation: 74420
You need to set name
attribute in order to get input value send on FORM submit.
Upvotes: 2
Reputation: 453
If you have a code-generated HiddenField, it needs to have the same ID and be created before the Page sets the posted values, such as in OnInit.
The following link may help you :
http://www.codeproject.com/Articles/3684/Retaining-State-for-Dynamically-Created-Controls-i
You can use:
protected string disabledState = "";
protected void Page_Load(object sender, EventArgs e)
{
this.disabledState = Request.Form["disabledState"];
}
In javascript you can use the following :
var disabledState ;
window.onload = function () {
disabledState = document.getElementById('"+disabledState_id+"');
};
Upvotes: 0