title: Clicking on cancel on Javascript Confirm box does not stop the grid from refreshing
body: <p>How to stop the page from rendering the <code>.cs</code> code on click of cancel button on javascript confirm box?</p>
  
  <p>I have a button click event and in some <code>IF</code> condition I am asking the user to confirm. Now when the user clicks on OK button, I have to bind the new data in a grid. but if the user clicks on cancel button, it should not refresh the grid with new data. </p>
  
  <p>Question: On click of cancel button on JavaScript confirm box, how can I stop the following code to be executed, or how can I just return/break from JavaScript?</p>
  
  <p>Can anyone please help me out with this? Thanks in advance.</p>
  
  <p><strong>Markup</strong></p>
  
  <pre><code>&lt;asp:Button ID="btnCopy" runat="server" Text="Copy" Enabled="false" OnClick="btnCopy_Click" ValidationGroup="Copy" /&gt;
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>public void btnCopy_Click(object sender, EventArgs e) { 
      if (Convert.ToInt32(hidId.Value) &gt; 0) {
          string scriptString = "&lt;script language='JavaScript'&gt; ";
          scriptString += "if (confirm('Are you sure to proceed?') == false) {return} ";
          scriptString += "&lt;/script&gt;";
          Page.RegisterStartupScript("Confirm", scriptString);
          BindDataGrid();
      }
  }
  </code></pre>