title: JavaScript Confirm on ASP.Net Button Control
body: <p>I working on an ASP.Net C# application, I wanted to create a Button Control, when user click on the button, a JavaScript confirm popup, then get the Boolean value from the user (Yes/No) to perform further actions in the button onClick event.</p>
  
  <p>my current approach was added OnClientClick and OnClick event in the button, where OnClientClick trigger JavaScript function and the (Yes/No) value is store into HiddenField Control to make use during OnClick event.</p>
  
  <p>It is something like the following code fragments:</p>
  
  <pre><code>function CreatePopup(){
              var value = confirm("Do you confirm?");
              var hdn1 = document.getElementById('hdn1');
              hdn1.Value = value;
          }
  
  &lt;asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" OnClientClick="CreatePopup()"/&gt;
  &lt;asp:HiddenField ID="hdn1" runat="server" /&gt;
  </code></pre>
  
  <p>Is there any better approach in order to do this? thank you in advanced.</p>