Reputation: 23505
im trying this format:
$("#<%= hfWidth.UniqueID %>").val($("#drag").attr("offsetWidth"));
to fill the hidden field with client-side values
but when I do postback, the values doesn't seem to be saved.
help
Upvotes: 0
Views: 21214
Reputation: 7959
in your aspx page:
<asp:HiddenField ID="hdn_checkbox" runat="server" />
in your Javascript:
function somefunction() {
$("#<%= hdn_checkbox.ClientID %>").val("test");
}
$('.btnGreen').click(function () {
somefunction();
alert($("#<%= hdn_checkbox.ClientID %>").val());
return true;
});
Upvotes: 0
Reputation: 81711
If you want to get params from the server side, you should use name instead of id attribute.
And your code should work :
$("#elementId").val("value");
Upvotes: 3