Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Related to Questions at:
- a) http://groups.google.com/group/dotnetdevelopment/browse_thread/thread/99e294a7d64c4034/
- b) http://groups.google.com/group/dotnetdevelopment/browse_thread/thread/6e502f3c0e182093
- --%>
- <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>Untitled Page</title>
- <script type="text/javascript" language="javascript">
- function ToggleCheckBoxes(check)
- {
- var tvID = "<%= TreeView1.ClientID %>".concat("n0Nodes");
- var tvNodes = document.getElementById(tvID);
- var chkBoxes = tvNodes.getElementsByTagName("input");
- for (var i = 0; i < chkBoxes.length; i++)
- {
- var chk = chkBoxes[i];
- if (chk.type == "checkbox")
- {
- chk.checked = check;
- }
- }
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <asp:TreeView ID="TreeView1" ShowCheckBoxes="Leaf" runat="server">
- <Nodes>
- <asp:TreeNode Text="Parent1" Expanded="true">
- <asp:TreeNode Text="Child1" Checked="true">
- <asp:TreeNode Text="Child2" Checked="true" />
- </asp:TreeNode>
- <asp:TreeNode Text="Child3" />
- <asp:TreeNode Text="Child4" />
- </asp:TreeNode>
- </Nodes>
- </asp:TreeView>
- <a href="javascript:void(0)" onclick="ToggleCheckBoxes(true);">Check all</a>
- <br />
- <a href="javascript:void(0)" onclick="ToggleCheckBoxes(false);">Uncheck all</a>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment