在ASP.NET中,在树形菜单(TreeView)前面加上TextBox,让一个TextBox选中,其余TextBox全选中,怎么写呀,求代码解析!!

解决方案 »

  1.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %><!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 id="Head1" runat="server">
        <title>无标题</title>
        <script type="text/javascript">
            // 全选
            function checkall() {
                var all = document.getElementsByTagName("input");
                for (var i = 0; i < all.length; i++) {
                    if (all[i].type == "checkbox") {
                        all[i].checked = true;
                    }
                }
            }
            //反选
            function checknull() {
                var all = document.getElementsByTagName("input");
                for (var i = 0; i < all.length; i++) {
                    if (all[i].type == "checkbox") {
                        all[i].checked = false;
                    }
                }
            }
        </script></head>
    <body onload="listpage()">
        <form id="form1" runat="server">
        <div>
            <div id="str">
            </div>
            <input type="checkbox" id="Checkbox1" value="1" />测试1<br/>
            <input type="checkbox" id="Checkbox2" value="2" />测试2<br/>
            <input type="checkbox" id="Checkbox3" value="3" />测试3<br/>
            <input type="checkbox" id="Checkbox4" value="4" />测试4<br/>
            <input type="checkbox" id="Checkbox5" value="5" />测试5<br/>
            <input type="checkbox" id="Checkbox6" value="6" />测试6<br/>
            <input type="checkbox" id="Checkbox7" value="7" />测试7<br/>
            <input type="checkbox" id="Checkbox8" value="8" />测试8<br/>
            <input type="checkbox" id="Checkbox9" value="9" />测试9<br/>
            <input id="Button1" type="button" value="全选" onclick="checkall()" />
            <input id="Button2" type="button" value="反选" onclick="checknull()" />
        </div>
        </form>
    </body>
    </html>可以看看,正反选的
      

  2.   

    在ASP.NET中,在树形菜单(TreeView)前面加上TextBox,让一个TextBox选中,其余TextBox全选中,怎么写呀,求代码解析!! 加在树形菜单前的checkBox!