asp.net javascript: get innertext of treeview
<p>i have a treeview on a web forms application.</p>

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

<pre><code>&lt;script type="text/javascript"&gt;
              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 &gt; 1)
                      nodeValue = nodeValues[nodeValues.length - 1];
                  else
                      nodeValue = nodeValues[0].substr(1); return nodeValue;
              }
&lt;/script&gt;
</code></pre>

<p><strong>question</strong>: 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?</p>

<p>here is the markup of the treeview:</p>

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