title: Telerik RadTextBox ValueChanged event and window.onbeforeunload
body: <p>I have the following javascript on my page:</p>
  
  <pre><code>var isDirty = false;
  
  function OnTextBoxValueChanged(sender, args)
  {
   isDirty = true;
  }
  
  window.onbeforeunload = function ()
  {
   if (isDirty)
   {
     return 'You have unsaved changes on the form.';
   }
  }
  </code></pre>
  
  <p>OnTextBoxValueChanged is the handler for RadTextBox's corresponding client event.</p>
  
  <p>if user changes text in textbox, then moves focus to any other element and then presses 'close tab' in browser - confirmation window appears. This is correct. But the problem appears when user changes text and then immediately presses 'close tab'. In this case onbeforeunload event fires before onvaluechanged and isDirty variable has incorrect value (false) in onbeforeunload handler.</p>
  
  <p>Am I doing something wrong or is there a workaround for my case?</p>