title: get a codebehind value in javascript function
body: <p>I want to get a codebehind value in my javascript function. My scenario is, Lets say I have two Usercontrols A and B.
  I am setting a global value from UserControl A. When I come to UserControl B's page load, I am accessing that value and putting it into a hidden field. 
  I have a button on UserControl B which calls a javascript function on client click.
  On that function I am trying to catch the hiddenfields current value. But I always get 0 from the hidden field value. What I am doing wrong? Can someone help me?</p>
  
  <p>Below is the code:</p>
  
  <pre><code>&lt;%@ Control Language="vb" AutoEventWireup="false" CodeBehind="DetailsForm.ascx.vb" Inherits="TD_Web_App.DetailsForm" %&gt;
  &lt;script type="text/javascript"&gt;
  function GetNextRecord() {
      debugger;
      var currentVal = $get("DetailsFormPanel_DetailsForm1_HFDetails").value; 
  //clientID of my hidden field
  }
  &lt;/script&gt;
  &lt;asp:UpdatePanel ID="DetailInfoUpdatePanel" runat="server" UpdateMode="Conditional" &gt; 
  
    &lt;ContentTemplate&gt;
  &lt;table id="TDPropsGrid" runat="server" width="250px" &gt;&lt;/table&gt;
      &lt;asp:Button ID="Cmd_Next" runat="server" Text="Next" Width="100px" SkinID="ButtonSkin" UseSubmitBehavior="false" OnClientClick="GetNextRecord()"/&gt;
  &lt;asp:LinkButton ID="LinkButtonDetails" runat="server" style="display:none;"&gt;
  LinkButton 
  &lt;/asp:LinkButton&gt;
  &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  
  &lt;asp:HiddenField ID="HFDetails" runat="server" /&gt;
  </code></pre>
  
  <p>On code behind:</p>
  
  <pre><code> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      showData() 'some function
      HFDetails.Value = CurrentRecordCounter  ' global value coming from other usercontrol 
  End Sub
  
  'Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
  '    HFDetails.Value = CurrentRecordCounter
  'End Sub
  </code></pre>
  
  <p>I have tried putting </p>
  
  <pre><code>&lt;asp:HiddenField ID="HFDetails" runat="server" /&gt; 
  </code></pre>
  
  <p>inside the update panel, nothing changed.</p>
  
  <p>But at GetNextRecord() the currentVal is always "0". why?</p>