title: HiddenField Value Lost on Postback
body: <p>I have some JavaScript that sets the value of a <code>HiddenField</code> and then forces a postback. I can trace through this JavaScript and it appears to work correctly. However, when I test the value of the <code>HiddenField</code> from the page's Load event, it is no longer set.</p>
  
  <p>Searching the web, I see a lot of posts about losing <code>HiddenField</code> values but none of them seemed to be doing the same thing that I am.</p>
  
  <p>Here's my JavaScript function (modified):</p>
  
  <pre><code>function EditItemItem(itemId) {
      document.getElementById('&lt;%= EditItemId.ClientID %&gt;').value = itemId;
      __doPostBack('&lt;%= EditItemUpdatePanel.ClientID %&gt;', '');
  }
  </code></pre>
  
  <p>And here's part of my markup (modified):</p>
  
  <pre><code>&lt;div id="EditItemBox" runat="server"&gt;
      &lt;asp:HiddenField runat="server" id="EditItemId" /&gt;
      &lt;asp:UpdatePanel ID="EditItemUpdatePanel" runat="server"
          UpdateMode="Conditional"&gt;
          &lt;ContentTemplate&gt;
          &lt;asp:Panel ID="EditItemPanel" runat="server"
              CssClass="ModalDialog" style="display:none;"&gt;
              &lt;div&gt;Edit an Item&lt;/div&gt;
              &lt;!-- ... --&gt;
          &lt;/asp:Panel&gt;
      &lt;/asp:UpdatePanel&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Does anyone have any ideas?</p>