title: Javascript onclick: how to pass the event variable?
body: <p>I have an <code>&lt;asp:Panel&gt;</code>, and when the user clicks on it, I want to show a <code>&lt;div&gt;</code> using Javascript. I do this to prevent the need of a postback to the server (I want a highly interactive client side showing/hiding of subcontent). I use the following code:</p>
  
  <pre><code>&lt;asp:Panel runat="server" ID="FilterButton" OnClick="showFilterPanel(); return false;"/&gt;
  
  function showFilterPanel()
  {
      //do some code that shows the div...
  }
  </code></pre>
  
  <p>This works because of the <code>return false;</code> statement at the end. I would now like to change the function to use <code>e.stopPropagation()</code> instead of the <code>return false;</code> inside the html. I was told this is the better way of doing this, but I'm not 100% sure what the differences are between "<code>return false;</code>" and "<code>e.stopPropagation()</code>", and why one is better than the other.</p>
  
  <p>Either way, I don't know the correct syntax of how to pass the event. I tried the following but the parameter e is not correctly passed:</p>
  
  <pre><code>&lt;asp:Panel runat="server" ID="FilterButton" OnClick="showFilterPanel(sender);"/&gt;
  
  function showFilterPanel(e)
  {
      //do some code that shows the div...
      e.stopPropagation();
  }
  </code></pre>
  
  <p>The following don't seem to work either:</p>
  
  <pre><code>&lt;asp:Panel runat="server" ID="FilterButton" OnClick="showFilterPanel(this);"/&gt;
  &lt;asp:Panel runat="server" ID="FilterButton" OnClick="showFilterPanel(event);"/&gt;
  &lt;asp:Panel runat="server" ID="FilterButton" OnClick="showFilterPanel(e);"/&gt;
  </code></pre>
  
  <p>I tested the correctness by using an alert message if the function runs, and checking for javascript errors. The errors I get were: "e is undefined" and "stopPropagation is not a method for object".</p>