Monday, March 22, 2010

how to access your asp.net controls in jquery.

$(document).ready(function() {
var id = " < % = chklstFilesAvailable.ClientID % > ";
var chklist = $("#" + id);
var btnId = " < % = btnDownload.ClientID % > ";
var button = $("#" + btnId);
//reusable show/hide button wiring
wireButtonShowToCheckListBox(chklist, button);
});

function wireButtonShowToCheckListBox(chklist, button) {
chklist.find('input:checkbox').each(function() {
var cb = $(this);
cb.click(function() {
var hit = false;
chklist.find('input:checkbox').each(function() {
var checked = $(this).attr('checked');
if (checked)
hit = true;
});
if (hit == true) {
button.show();
} else {
button.hide();
}
});
});

}

Refer to this article for more details

No comments:

Post a Comment