title: Stop propagation of a JavaScript event defined using Attributes in ASP.Net
body: <p>I have defined the client-side click event for a link in the code-behind of an ASP.Net page. This code is in VB.Net as below and it uses <code>Attributes</code> collection of link control to add this client-side event. This event is executing as expected, but I cannot get a handle on the `event' argument for stopping event propgation.</p>
  
  <p><strong>Question</strong></p>
  
  <p>How can I access the <code>event</code> argument so that the <code>stopPropagation</code> method can be called to prevent the click event of a parent div from firing?</p>
  
  <pre><code>Dim link As System.Web.UI.WebControls.LinkButton = DirectCast(sender,
                                                        System.Web.UI.WebControls.LinkButton)
  
         link.Attributes.Add("onclick", "OnEmployeeClick('" &amp; 
         dataRowItem("EmployeeId").ToString() &amp; "','" &amp; link.ClientID &amp; "'); 
         return false; ")
  </code></pre>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>As suggested by dandavis, I simply used the automatically available <code>event</code> argument, and it worked. I added new code of <code>event.stopPropagation();</code> just before the <code>OnEmployeeClick</code> method call in the <code>onclick</code> definition in code-behind.</p>
  
  <pre><code>   Dim link As System.Web.UI.WebControls.LinkButton = DirectCast(sender,
                                                      System.Web.UI.WebControls.LinkButton)
  
     link.Attributes.Add("onclick", "event.stopPropagation();OnEmployeeClick('" &amp; 
     dataRowItem("EmployeeId").ToString() &amp; "','" &amp; link.ClientID &amp; "'); 
     return false; ")
  </code></pre>