Reputation: 595
i am nwe to jquery.how i get value of hidden field after post back in csharp. when ever post back occures value dissapear. this is my hidden field.
<asp:HiddenField ID="Hid_BasicSalary" runat="server" />
this is jquery code where is assign data to it after succsesful execution of ajax web service.
var BasicSalary = $('Hid_BasicSalary');
BasicSalary.val(data["BasicSalary"]);
this is c sharp code when i click on button postback occurs afte this node data.
protected void Btn_PIncrementSave_Click(object sender, EventArgs e)
{
try
{
TxBx_IncrementAmount.Text = Hid_BasicSalary.Value.ToString();
}
catch (Exception ex)
{
Utility.Msg_Error(this.Master, ex.Message);
}
}
please help me
Upvotes: 4
Views: 816
Reputation: 1126
In jQuery we use the selector for select any elements, and we have to put .
for the class and #
to the id selector so please put #
or .
before your element.
In your case, $('#Hid_BasicSalary');
or $('.Hid_BasicSalary');
is your answer.
Upvotes: 3
Reputation: 1697
try this to get value of server control from javascript/jquery
var BasicSalary = document.getElementById('<%=Hid_BasicSalary.ClientID%>').value
Upvotes: 0
Reputation: 91
you missed the "#" and i think that you should use the hidden control's clientid.
var BasicSalary = $('#<%=Hid_BasicSalary.ClientID%>');
Upvotes: 1
Reputation: 595
i was missing # with $.
var BasicSalary = $('Hid_BasicSalary');
i write this instead of this
var BasicSalary = $('#Hid_BasicSalary');
Upvotes: 2
Reputation: 4489
Use This code is page load to get new value from hidden
Request.Form["hdnvalue"];
Upvotes: 1