title: Value of Hiddenfield not found in javascript function
body: <p>I have spent the couple days researching my issue and have not been able to get it to work correctly.  I know there are a few topics here that are related to this issue and reading them has helped me but I'm at a bit of a roadblock and would appreciate a push in the right direction.</p>
  
  <p>I wrote a small .NET 3.5 VB.NET web application that allows users to maintain some data.  It consists of 3 pages.  One requirement I was not completely fond of was that the user wanted to make all of her changes then hit a save button at the end instead of saving back to the DB each time she applied her changes to the grid.  </p>
  
  <p>I'm using an session object to store a collection of objects on each page and want to prompt the user with a dialog if they attempt to change the value of a dropdown or leave the page when there are pending actions.  After a lot of research here and in other places, I decided to create a hidden field on the page and update its value each time the action collection is updated on the server side.  Then I want to evaluate that value and if it's greater than 0, I want to prompt the user to save changes.</p>
  
  <p>My function:</p>
  
  <pre><code>&lt;telerik:RadCodeBlock ID="RadCodeBlock2" runat="server"&gt;
      &lt;script type="text/javascript"&gt;
          window.onbeforeunload = confirmExit;
          function confirmExit()
          {
              var actionCount = $get('&lt;%=ActionCounterField.ClientID %&gt;').value;
              if (actionCount &gt; 0) {
                  alert("Pending Changes!");
                    }
              }
  
          &lt;/script&gt;
      &lt;/telerik:RadCodeBlock&gt;
  </code></pre>
  
  <p>My hidden field declaration:</p>
  
  <pre><code>&lt;asp:HiddenField id="ActionCounterField" runat="server" /&gt;
  </code></pre>
  
  <p>My server side code:</p>
  
  <pre><code>Protected Sub UpdateActionCount()
  
      ActionCounterField.Value = GoalCategoryActionList.Count
  
  End Sub
  </code></pre>
  
  <p>When I debug the application and add a record to my grid, the server side code is executed correctly.  I have also verified that the hidden control is found by the javascript function.  What I haven't been able to figure out, though, is why the hidden field value is not found by the function.</p>
  
  <p>Any help is greatly appreciated.  Thank you!</p>