title: How can I make my webpage run JavaScript code when an ASP.net control is clicked?
body: <p>I have a web page that uses the ASP.net Tree View web control.  As the web page is currently programmed, when the user clicks on a node on the tree view, the page posts back and a C# function executes to handle the event.</p>
  
  <p>Can I make my web page run some Javascript code and <em>not</em> post back when a tree view node is clicked?</p>
  
  <p><b>Update:</b>  Suppose my page looks like the one below.  How can I make it so that clicking on <code>node_A</code> is handled by Javascript client-side instead of C# server-side?</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication3.WebForm2" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
      &lt;asp:TreeView runat="server" ID="myTreeView"&gt;
      &lt;Nodes&gt;
          &lt;asp:TreeNode Text="node_A" Value="1" /&gt;
          &lt;asp:TreeNode Text="node_B" Value="2" /&gt;
          &lt;asp:TreeNode Text="node_C" Value="3" /&gt;
      &lt;/Nodes&gt;
      &lt;/asp:TreeView&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>