how to get the value of a HiddenFor control in jquery

18,833

I could be wrong, but isn't it merely that:

var id = $("#SchedulingProfile_Id").val();

needs to be:

var id = $("#SchedulingProfileDetails_Id").val();

?

Share:
18,833
Rituraj Mishra
Author by

Rituraj Mishra

Updated on July 11, 2022

Comments

  • Rituraj Mishra
    Rituraj Mishra almost 2 years

    i have a hidden for control as

    @Html.HiddenFor(m => m.SchedulingProfileDetails.Id)
    

    I am trying to access the value in this hidden field in my jquery and then trying to pass the value to controller

      var id = $("#SchedulingProfile_Id").val();
    
                            $.ajax({
                                url: rootUrl + 'SchedulingProfile/SaveDetails',
                                type: "POST",
                                data: ({
                                    schedulingProfileId: schedulingProfileId, 
                                       });
    

    but I am getting null value in id. Please help me out