The JQuery settings checkbox Select Radio is read-only, and by testing the text and textarea that use HTML tags, the button can set the readonly= "ReadOnly" property.
However, the checkbox, select, radio three controls cannot be used with the readonly= "ReadOnly" property, only disabled= "disabled" can be used.
So there's a problem. Also want to not let the changes, and want to get the value in the background. If you use the Disabled property, but you find (string value = request.form["XX"];) value is empty.
Do not want to modify the background code, and finally in the discussion with Bogo, finally came up with the following method.
[HTML]View Plaincopyprint?
- <%@ page language="C #" autoeventwireup="true" codefile="Default.aspx.cs" inherits= "_default"%>
- <! 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 runat="Server">
- <title></title>
- <script src="scripts/jquery-1.4.1.min.js" type="Text/javascript"> </Script>
- <script type="Text/javascript">
- function Setscr_readonly () {
- var items = $ ("input[type=' checkbox ']")
- var html = ""
- for (var i = 0; I < items.length; i++) {
- Items[i]. Disabled = true;
- HTML + = "<input type=' text ' name='" + items[i].id + "' value='" + items[i].value + "' > ";
- }
- var items = $ ("select");
- for (var i = 0; I < items.length; i++) {
- HTML + = "<input type=' text ' name='" + items[i].id + "' value='" + Items[i].value + "' > ";
- Items[i]. Disabled = true;
- }
- var items = $ (": Radio");
- for (var i = 0; I < items.length; i++) {
- HTML + = "<input type=' text ' name='" + items[i].id + "' value='" + items[i].value + "' > ";
- Items[i]. Disabled = true;
- }
- $ ("#divhtml"). HTML (HTML);
- }
- </Script>
- </head>
- <body>
- <form id="Form1" runat="Server">
- <div>
- <input type="text" readonly="readonly" />
- <input type= "button" value=< Span class= "Attribute-value" > "not available" onclick= "Setscr_ ReadOnly () " />
- <input type="checkbox" id="R" checked="checked" runat="Server " value="Cbovalue" />
- <Select id="sel" name="sel">
- <option value="Please select"> select </option>
- <option value="1">1</option>
- </Select>
- <Select id= "Select1" name="Select1">
- <option value="Please select"> select </option>
- <option value="1" selected="selected">1</option>
- </Select>
- <input id= "RDO" name= "RDO" type= "Radio" < span class= "attribute" >value= "1" checked= "checked" />
- <Asp:button runat="Server" text="button" onclick="Unnamed1_click" />
- <div style="Display:none" id="divhtml">
- </div>
- </div>
- </form>
- </body>
- </html>
<%@ page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default"%><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">