I'm encountering an issue in my asp.net application where I have an html table. Specifically, when a user clicks on a td element within the table, I use JavaScript to store the id of that td element in a hidden field. Afterwards, I trigger __dopostback from JavaScript in order to utilize the value stored in the hidden field in the code behind.
Here's a snippet of the HTML:
<td id="m1" onclick="">Jan</td>
<td id="m2" onclick="">Feb</td>
The JavaScript code looks like this:
$('.window td').on('click', function () {
var idName = this.id;
var selectedid = idName.substring(1);
console.log(selectedid);
$('#hidden').val(selectedid);
_doPostBack(idName , '');
});
My current problem is that whenever I click anywhere on the page, it triggers the __doPostBack method. However, I only want this method to be called when a td element is clicked.
Does anyone know how to prevent __doPostBack from being triggered when the user clicks elsewhere on the page?