title: ASP.NET/JavaScript - Why Isn't "Return False" Not Preventing Postback?
body: <p>I feel like i've done this scenario plenty of times, and it usually works, so im obviously missing something.</p>
  
  <p>Here's my server-side ASP.NET Button:</p>
  
  <pre><code>&lt;asp:Button ID="btnFoo" runat="server" Text="Foo" CssClass="button foo" OnClientClick="foo_Click();" /&gt;
  </code></pre>
  
  <p>Which get's rendered on the client as:</p>
  
  <pre><code>&lt;input type="submit" name="reallylongclientid" value="Foo" onclick="foo_Click();WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(reallylongclientidandpostbackoptions, false, false))" id="reallylongclientid" class="button foo"&gt;
  </code></pre>
  
  <p>No surprises there.</p>
  
  <p>Here's the surprise, in my JavaScript function:</p>
  
  <pre><code>function foo_Click() {
     return false;
  }
  </code></pre>
  
  <p>Okay so there's more to it than that, but i cut it down to prove a point.</p>
  
  <p>When i click the button, it calls the client-side function, and returns false.</p>
  
  <p>But it still posts back to the server, why?</p>
  
  <p>I basically want to do this on the click of the button:</p>
  
  <ol>
  <li>Do client-side validation.</li>
  <li>If validation passes, post back</li>
  <li>If not, show some error messages on the form.</li>
  </ol>
  
  <p>Of course, i could change this to an client-side button (input type="button") and <em>manually</em> kick off the postback when i want, but i shouldn't need to do that. Or should i?</p>