I have hundreds of checkboxes that are dynamically created with different values. They are all the same id. I am using asp.net c# checkbox.
Without looping through all of the checkboxes, I'd like to only deal with the checkbox I actually click. Basically, the same behavior you would get using JQuery $(this).val(); for example.
I know this can be done using Jquery but I need to do it with C#. I'm trying to figure how to do the equivalent of the code below in C#.
$('.maingrid input[type=checkbox]').click(function() {
var value = $(this).next("label").text();
console.log(value);
});
Create an event handler and set the checkboxes onCheckedChanged
see here event to that event handler. When the event is called, cast the sender
to a CheckBox in to a var and go from there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.