我正在創建一個控件,可以在單擊按鈕時啓用/禁用一個aspx頁面。我在jquery中找到了一個代碼片段,它可以爲所有值做到這一點,但我想限制鎖定/編輯部分爲一個asp面板。啓用/禁用jQuery切換和ASP面板
1)這可能嗎?
2)如何更改jquery代碼以僅切換Panel1中的字段?
我對Jquery很新。
謝謝任何和所有未來的指導!
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChangeControl3.aspx.cs" Inherits="Test_ChangeControl3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta charset=utf-8 />
<title>Test Lock/Edit Control</title>
<link type="text/css" rel="Stylesheet"href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.5/themes/redmond/jquery-ui.css" />
<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() {
$("*").attr("disabled", "disabled");
$(this).attr("disabled", "");
}, function() {
$("*").attr("disabled", "");
});
});
</script>
</head>
<body>
<form runat="server">
<asp:Panel ID="Panel1" runat="server">
<div>
<asp:Label runat="server" ID="lblFname" Text="First Name:" ></asp:Label>
<asp:TextBox runat="server" ID="fname"></asp:TextBox>
</div>
<div>
<asp:Label runat="server" ID="lblLname" Text="Last Name:"></asp:Label>
<asp:TextBox runat="server" ID="lname"></asp:TextBox>
</div>
<div>
<asp:Label runat="server" ID="lblCompany" Text="Company:" ></asp:Label>
<asp:TextBox runat="server" ID="cname"></asp:TextBox>
</div>
</asp:Panel>
<br />
<asp:Button runat="server" id="btnEnableDisable" Text="Lock/Edit" />
<br />
<input type="checkbox" name="qrentown" value="Do you own a home?" /> Do you own a home?<br /><br/>
<select name="rentown">
<option value="own">Own</option>
<option value="rent">Rent</option>
<option value="none">N/A</option>
</select><br/>
<input readonly="readonly" value="Describe your living situation"/><br />
<textarea rows="3" cols="40" > </textarea>
<br/><br/>
</form>
</body>
</html>