title: Why asp:UpdatePanel updates hiddenfield value only on second click on button
body: <p>I have problem while updating hiddenfield on button click. When I click on button,
  it does not update hiedenfield for <strong>first</strong> time, only if I click button <strong>second</strong> time
  then I am getting correct value. I searched on web for this and I could not find solution for this. Does anyone know why it is happening and is it default behaviour or if someone can provide me some other usefull approach to solve this problem. </p>
  
  <p>.aspx file: </p>
  
  <pre><code>&lt;asp:ScriptManager ID="scriptManager" runat="server"&gt;
  &lt;/asp:ScriptManager&gt;
  &lt;asp:RadioButtonList ID="radioQuestion" runat="server"&gt;
      &lt;asp:ListItem Text="first" Value="first"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Text="second" Value="second"&gt;&lt;/asp:ListItem&gt;
  &lt;/asp:RadioButtonList&gt;
  &lt;asp:UpdatePanel ID="updateResult" runat="server" &gt;
      &lt;ContentTemplate&gt;
          &lt;asp:HiddenField ID="hiddenResult" runat="server" /&gt;
      &lt;/ContentTemplate&gt;
      &lt;Triggers&gt;
          &lt;asp:AsyncPostBackTrigger ControlID="btnCheck" EventName="Click" /&gt;
      &lt;/Triggers&gt;
  &lt;/asp:UpdatePanel&gt;
  &lt;asp:Button ID="btnCheck" runat="server" OnClick="btnCheck_Click" Text="Check"
      CssClass="check"  /&gt; 
  </code></pre>
  
  <p>Javascript code:</p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $('.check').click(function () {
              alert($('#hiddenResult').val());
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>.cs file:</p>
  
  <pre><code> protected void btnCheck_Click(object sender, EventArgs e)
  {
      switch (radioQuestion.SelectedValue)
      {
          case "first":
              hiddenResult.Value = "YES";
              break;
          case "second":
              hiddenResult.Value = "NO";
              break;
      }
  }
  </code></pre>