Check All Checkboxes in Gridview Using Jquery: Select All and Highlight Selected Row
Check All Checkboxes in Gridview Using Jquery: Select All and Highlight Selected Row
Checking all checkboxes when we select the checkbox in header is one of the most common
requirements in ASP.Net application. The following article will help you to do this in JavaScript.
Select All and Highlight Selected Row
The folllowing code snippet will help us to do the same using JQuery.
<script language="javascript">
function SelectAllCheckboxes(chk) {
$('#<%=gvUsers.ClientID %>').find("input:checkbox").each(function() {
if (this != chk) {
this.checked = chk.checked;
}
});
}
</script>
function SelectAllCheckboxes(chk) {
$('#<%=gvUsers.ClientID %> >tbody >tr >td >input:checkbox').attr('checked', chk.checked);
}
How to disable the page or All Page control using jQuery in ASP.Net?
The introduction of jQuery has made every client side operations a lot easier. This little jquery snippet
will help you to disable the whole page controls at a stretch.
It is very easy to access all the page controls using the jQuery selector expression. The below jquery
script will select all the page controls and will set the disabled attribute.
<script src="_scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script language="javascript">
$(document).ready(function() {
$("#btnDisable").click(function() {
$("*").attr("disabled", "disabled");
});
});
</script>
How to Enable and Disable all Input control using jQuery in ASP.Net?
Sometimes, we will have requirements to disable all the input control in aspx page to prevent users
from providing some inputs. This little jquery snippet will help us to disable all the input controls in
our page to be disabled except button control.
Refer below,
<head runat="server">
<title></title>
<script src="_scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script language="javascript">
$(document).ready(function() {
$("#btnReset").toggle(function() {
$("INPUT:not(INPUT[type=button]),SELECT,TEXTAREA").attr("disabled",
"disabled");
}, function() {
$
("INPUT:not(INPUT[type=button]),SELECT,TEXTAREA").removeAttr("disabled");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
</asp:DropDownList>
<asp:ListBox ID="ListBox1" runat="server">
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:ListBox>
<asp:CheckBox ID="CheckBox1" runat="server" Text="eeee" />
<asp:RadioButton ID="RadioButton1" runat="server" Text="eeee" />
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:CheckBoxList>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:RadioButtonList>
<input ID="btnReset" type="button" value="ResetAll" />
</div>
In the above code, all the input controls will get disabled on click of the reset button and it will get
enabled on the next click (toggle).