I have an html table in my asp.net application. When a td element is clicked, I store that value in a hidden field using JavaScript.
function rebind() {
$('.window td').on('click', function () {
var idName = this.id;
var selectedid = idName.substring(1);
console.log(selectedid);
$('#hidden').val(selectedid);
});
}
Now, I want to reload this aspx page after this click event because I need new data to be displayed as per the td value and I also want to preserve this hidden field value after reload or refresh and I want to use it on server side (aspx.cs).
I've tried ajax like this,
$.ajax({
url: "Default.aspx",
data: selectedid,
type: "POST",
success: function (result) {
alert('Yay! It worked!');
},
error: function (result) {
alert('Error');
}
});
But I am not able to access selectedid variable on c# side. I want to know if I am going in the right direction?