Here I will explain how to enable or disable selected or particular controls on a page using JQuery in asp.net.
In previous articles I explained how to disable or enable all the controls on page using JQuery and many articles relating to JQuery. Now I will explain how to disable or enable only selected or particular controls on webpage using JQuery in asp.net.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Disable or Enable All Controls on a Page</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function()
{
$("#btnEnableDisable").toggle(function() {
$("input:not(.disb),textarea,select").attr("disabled", "disabled");
$(this).attr("disabled", "");
}, function()
{
$("*").attr("disabled", "");
});
});
</script>
</head>
<body>
<form id="form1"
runat="server">
First name: <asp:TextBox ID="txtfname" runat="server"/><br />
Last name: <asp:TextBox ID="txtlname" runat="server"/><br />
Password: <asp:TextBox ID="txtpwd" runat="server"/><br/>
<asp:RadioButtonList ID="rdbtn"
runat="server">
<asp:ListItem Value="male" Text="Male"/>
<asp:ListItem Value="female" Text="Female"/>
</asp:RadioButtonList>
<asp:CheckBoxList ID="chkVehicle"
runat="server">
<asp:ListItem Value="Bike" Text="I have a bike"/>
<asp:ListItem Value="Car" Text="I have a car"/>
</asp:CheckBoxList>
<asp:DropDownList ID="ddlBuses"
runat="server">
<asp:ListItem Value="volvo" Text="Volvo" />
<asp:ListItem Value="saab" Text="Saab"/>
<asp:ListItem Value="Audi" Text="Audi"/>
<asp:ListItem Value="ford" Text="Ford"/>
</asp:DropDownList><br/>
<textarea rows="5" cols="40" >
</textarea>
<br/>
<asp:Button ID="btnEnableDisable"
runat="server"
Text="Enable/Disable"
/>
</form>
</body>
</html>
|
$(document).ready(function()
{
$("#btnEnableDisable").toggle(function() {
$("input:not(.disb),textarea,select").attr("disabled", "disabled");
$(this).attr("disabled", "");
}, function()
{
$("*").attr("disabled", "");
});
});
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
|

Subscribe by RSS
Subscribe by Email
1 comments :
e werwer w