title: ConfirmationBox from codebehind, wait for answer
body: <p>From my code behind, in my update method, I have to ask the user if he wants to overide some particular value. If so, overide, if not, continue with the saving without saving this value.</p>
  
  <p>In my aspx I have this javascript function:</p>
  
  <pre><code>function ConfirmationBox(msg) {
      var ovd = document.getElementById("hdnOveride"); //gets a HiddenField
          if (confirm(msg) == true) {
              ovd.value = "1";
              return true;
          }
          else {
              ovd.value = "0";
              return false;
          }
      }
  </code></pre>
  
  <p>From codebehind, I call this function. And then I check the value of my HiddenField "hdnoveride". If its 1 I save, otherwise I don't. </p>
  
  <pre><code>System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Test", "javascript:ConfirmationBox('overide?');", true);
  
  if (hdnOveride.Value == "1"){
        //Save the value
  }
  </code></pre>
  
  <p>The problem is that my code doesn't wait for the user to answer the confirm box before it continues. I have tried using Thread.Sleep() while hdnOveride is not set like this:</p>
  
  <pre><code>while (hdnOveride.Value == "notset") {
      System.Threading.Thread.Sleep(500);
  }
  </code></pre>
  
  <p>But it just stops everything, so the popup box never shows when I do this.</p>
  
  <p>How can I tell the system to wait for an answer before continuing with the code?
  Thanks!</p>