Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6660975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:13:19+00:00 2026-05-26T02:13:19+00:00

i have a treeview on a web forms application. i have javascript function that

  • 0

i have a treeview on a web forms application.

i have javascript function that gets called every time there is a click inside the treeview:

<script type="text/javascript">
              function OnTreeClick(evt) {
                  var src = window.event != window.undefined ? window.event.srcElement : evt.target;
                  var nodeClick = src.tagName.toLowerCase() == "a";
                  if (nodeClick) {
                      var nodeText = src.innerText;
                      var nodeValue = GetNodeValue(src);
                      alert("Text: " + nodeText + "," + "Value: " + nodeValue);
                  }
                  //return false; //uncomment this if you do not want postback on node click
              }
              function GetNodeValue(node) {
                  //node value
                  var nodeValue = "";
                  var nodePath = node.href.substring(node.href.indexOf(",") + 2, node.href.length - 2);
                  var nodeValues = nodePath.split("\\");
                  if (nodeValues.length > 1)
                      nodeValue = nodeValues[nodeValues.length - 1];
                  else
                      nodeValue = nodeValues[0].substr(1); return nodeValue;
              }
</script>

question: how do i catch whether a user clicked on a checkbox inside the tree view? and how do i retrieve the text next to it?

here is the markup of the treeview:

 <asp:TreeView ID="TreeView1" runat="server" ShowLines="True" 
        onselectednodechanged="TreeView1_SelectedNodeChanged" 
        ontreenodecheckchanged="TreeView1_TreeNodeCheckChanged" CssClass="mytreeview"
        >
        <Nodes>
            <asp:TreeNode Text="PreAnalytical" Value="PreAnalytical">
                <asp:TreeNode Text="Labels" Value="Labels">
                    <asp:TreeNode Text="Specimen collection device mislabeled/unlabeled by practice" 
                        Value="Specimen collection device mislabeled/unlabeled by practice" 
                        ShowCheckBox="True">
                    </asp:TreeNode>
                    <asp:TreeNode Text="Specimen mislabeled: in-house error (Lab or DE)" 
                        Value="Specimen mislabeled: in-house error (Lab or DE)" 
                        ShowCheckBox="True"></asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="Test Requisitions" Value="Test Requisitions">
                    <asp:TreeNode Text="Missing: no form sent with specimen" 
                        Value="Missing: no form sent with specimen" ShowCheckBox="True"></asp:TreeNode>
                    <asp:TreeNode Text="Wrong (i.e. OT instead of ORAL, sister practice)" 
                        Value="Wrong (i.e. OT instead of ORAL, sister practice)" 
                        ShowCheckBox="True"></asp:TreeNode>
                    <asp:TreeNode Text="Other: Non-ML" Value="Other: Non-ML" ShowCheckBox="True"></asp:TreeNode>
                    <asp:TreeNode Text="Copies Received: New ID/Req. assigned" 
                        Value="Copies Received: New ID/Req. assigned" ShowCheckBox="True"></asp:TreeNode>
                    <asp:TreeNode Text="Incomplete/Blank Requisition Form" 
                        Value="Incomplete/Blank Requisition Form" ShowCheckBox="True"></asp:TreeNode>
                    <asp:TreeNode Text="2 Specimens: 1 Req" Value="2 Specimens: 1 Req" 
                        ShowCheckBox="True">
                    </asp:TreeNode>
                    <asp:TreeNode Text="2 Reqs: 1 Specimen" Value="2 Reqs: 1 Specimen" 
                        ShowCheckBox="True">
                    </asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="Validity" Value="Need POC Results Confirmed">
                    <asp:TreeNode Text="Need POC Results Confirmed" Value="New Node"></asp:TreeNode>
                    <asp:TreeNode Text="POC Results Marked Incorrectly" Value="New Node">
                    </asp:TreeNode>
                    <asp:TreeNode Text="No Tests Ordered" Value="New Node"></asp:TreeNode>
                    <asp:TreeNode Text="SEC A Unclear" Value="New Node"></asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="Sales" Value="Sales">
                    <asp:TreeNode Text="Practice is not entered in database" Value="New Node">
                    </asp:TreeNode>
                    <asp:TreeNode Text="CP has not been updated" Value="New Node"></asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="Other" Value="Other">
                    <asp:TreeNode Text="Other" Value="New Node"></asp:TreeNode>
                </asp:TreeNode>
            </asp:TreeNode>
            <asp:TreeNode Text="Analytical" Value="Analytical"></asp:TreeNode>
            <asp:TreeNode Text="Post-Analytical" Value="Post-Analytical"></asp:TreeNode>
            <asp:TreeNode Text="Other" Value="Other"></asp:TreeNode>
        </Nodes>
    </asp:TreeView>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:13:19+00:00Added an answer on May 26, 2026 at 2:13 am
    function check_OnTreeNodeChecked(event)
    {
        var TreeNode = event.srcElement || event.target ;
        if (TreeNode.tagName == "INPUT" && TreeNode.type == "checkbox")
        {
            if(TreeNode.checked)
            {
                //Do whatever here
            }
        }
    } 
    

    Then attach this function with treeview onclick event:

    private void Page_PreRender(object sender, EventArgs e)
    {
        TreeView1.Attributes.Add("OnClick", "check_OnTreeNodeChecked(event)");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a treeview control in a Windows Forms project that has checkboxes turned
I have a TreeView control in my WinForms .NET application that has multiple levels
In my web application I have a treeview with documents. The NavigateUrl of a
I have a treeview control in my web application. I build this tree view
I have a TreeView windows forms control with an ImageList , and I want
Using WPF, I have a TreeView control that I want to set its ItemTemplate
I have changed the Treeview.HideSelection = false; But how do I insure that when
Due to a security requirement all browsers that will run a web application we
I have a treeview which when visible takes too much space on the web
I have a treeview with nodes like this: Foo (1234), and want to allow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.