Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get value hidden in C# when it is set by jquery after postback

Tags:

jquery

c#

asp.net

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

like image 666
Amjad Shah Avatar asked Jan 14 '23 11:01

Amjad Shah


1 Answers

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.

like image 179
Developerzzz Avatar answered Feb 06 '23 12:02

Developerzzz