title: Disable page refresh after button click ASP.NET
body: <p>I have an asp button that looks like this:</p>
  
  <p>Default.aspx</p>
  
  <pre><code>&lt;asp:button id="button1" runat="server" Text="clickme" onclick="function" /&gt;
  </code></pre>
  
  <p>Default.aspx.cs</p>
  
  <pre><code>protected void function(object sender EventArgs e)
  {
      // Do some calculation
  }
  </code></pre>
  
  <p>However, whenever I press the button, the entire page gets refreshed. I have looked on this site and found many solutions, but none of them really works for my project. Here are some of the suggested solutions:</p>
  
  <ol>
  <li>set onclick="return false;" // but then how do I run the function in the code-behind?</li>
  <li>use !IsPostBack in Page_Load // but the page still refreshes completely. I don't want Page_Load to be called at all.</li>
  <li>Disable AutoEventWireup. // making this true or false doesn't make a difference.</li>
  </ol>
  
  <p>Does anyone have a solution to this, or is it really impossible?</p>