title: Prevent Postback after opening jQuery dialog box
body: <p>Page:</p>
  
  <pre><code>&lt;body&gt;
   &lt;form id="frmLogin" runat="server"&gt;  
    &lt;asp:Button ID="btnClick" OnClientClick="openConfirmDialog();" OnClick="PopulateLabel"  runat="server"/&gt;
    &lt;div id="divDialog"&gt;&lt;/div&gt;
    &lt;asp:Label ID="lblText" runat="server"&gt;&lt;/asp:Label&gt;
   &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
   $(document).ready(function() {
   $("#divDialog").dialog({autoOpen: false,
                       buttons: { "Ok": function()
                                        { 
                                           $(this).dialog("close");
                                        },
                                  "Cancel": function()
                                        { 
                                            $(this).dialog("close");
                                        }
                                } 
                     });
   });
  
   function openConfirmDialog()
   {
    $("#divDialog").dialog("open");
   }
  </code></pre>
  
  <p></p>
  
  <p>C#</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
   {
      lblText.Text = "";
   }
  
  protected void PopulateLabel(object sender, EventArgs e)
   {
      lblText.Text = "Hello";
   }
  </code></pre>
  
  <p>This code opens me a dialog box with Ok and Cancel button but it do not wait for user activity and post the page immediately and the label gets populated. I need to call the c# function based on user activity. If user clicks "Ok" label should get populated and if user clicks "Cancel" it should not call the c# function. How do I achieve this?</p>