I have set a session variable in the backend (code-behind ascx.cs page) and now I need to access that same value in a checkbox checked event using JavaScript.
Below is my JavaScript function code:
$(document).ready(function () {
$('#<%= gvPRCertInfo.ClientID %> input[type="checkbox"]').change(function () {
var background1 = null;
background1 = '<%= Session["FriendlyData"] %>';
alert(background1); // The value returned is 'system.data.dataset'
if ($(this).is(':checked')) {
var signValue =
$(this).closest('tr').children('td:eq(4)').html();
}
});
});
The variable <%= Session["FriendlyData"] %> contains a dataset with values assigned in the backend. However, when I try to access it in the JavaScript function above, the alert shows 'System.data.dataset' instead of the actual session value.
If anyone can provide guidance on how to correctly retrieve the dataset value in the JavaScript function, it would be greatly appreciated.
Thank you in advance!