asp.net - Javascript variable in asp block code -


i have lot of checkboxes needs execute same javascript function when checked/unchecked. parameter enclose control's server id. hope actual checkbox using id. problem need find client id, expected can't use javascript variable mycontrolsserverid inside asp code blocks id. stuck:

function show(mycontrolsserverid) {    var checkbox = document.getelementbyid('<%= mycontrolsserverid.clientid %>')    //more omitted code } 

how can clicked checkbox?

use jquery achieve this.

at document load initialize jquery listen checkboxes on page. moment click on 1 of these, can whatever want it:

$(document).ready(function() {     $("input:checkbox").click(function(e) {         alert($(this).attr('id'));     }); }); 

download latest jquery version on http://jquery.com/download/


Comments