by
Neon Quach
1. May 2010 18:14
By default there is no select all comments for deleting or approving these comments, in this blog i will show you the way to do this with jquery.
BlogEngine v1.6 don’t use jquery so we must get jquery library form here and reference it to admin’s master page if we are going to use this javascript framework in another admin page, or admin/Comment/DataGrid.ascx user control.
<script src="<%= ResolveUrl("~/Admin/jquery-1.3.2.js")%>" type="text/javascript"></script>
Now in DataGrid.ascx usercontrol, we will add new html checkbox in the header for selecting all checkboxes by adding either design view or source view. Here is markup:
<HeaderTemplate>
<input id="chkAll" type="checkbox" />
</HeaderTemplate>
In order up and running jquery i call “document ready” handler:
$(document).ready(function () {
});
and fire click event of chkAll checkbox input control
$("input[type=checkbox]").each(function () {
});
When the user click on the chkAll input control, i will loop for all checkboxes and check whether chkAll is checked or not, if chkAll is checked then all checkboxes have checked and vice versa, here is the code:
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$('#chkAll').click(function () {
$("input[type=checkbox]").each(function () {
if (this.checked == true) {
$("input[type=checkbox]").attr('checked', 'checked');
}
else {
$("input[type=checkbox]").attr('checked', false);
}
});
});
});
</script>
Hope this help!