I have defined hidden field in .aspx page(ui)
<asp:HiddenField ID ="hdnExport" runat="server" />
Set the value in the following code (java script)
$(document).ready(function () {
$("#btn_FinalConfirmOK").on("click", function (event) {
alert("clicked");
//document.getElementById("hdnExport").value = "yes";
$('#hdnExport').val("yes");
alert($('#hdnExport').val());
document.getElementById('hdnExport').value = "yes";
//alert("yes");
});
});
Then accessing hidden field value in aspx.cs code is given below,
string exportValue = Convert.ToString(hdnExport.Value);
string exp = hdnExport.Value.ToString();
var val = this.hdnExport.Value;
string latitudeValue = Request.Form[hdnExport.Value];
Tried with different ways. but i didn't get value from hidden field. how to solve this issue
By default, the rendered id will differ from the ID specified within C# (hdnExport). Therefore, (#hdnExport) is likely an invalid selector thus no value is set.
Try setting ClientIDMode="Static" on the HiddenField:
<asp:HiddenField ID ="hdnExport" ClientIDMode="Static" runat="server" />
This will ensure the hidden field is rendered with id as ID which would make #hdnExport valid.