title: Access an asp:hiddenfield control in JavaScript
body: <p>What is the best way to access an ASP.NET HiddenField control that is embedded in an ASP.NET PlaceHolder control through JavaScript?  The Visible attribute is set to false in the initial page load and can changed via an AJAX callback.</p>
  
  <p>Here is my current source code:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      function AccessMyHiddenField()
      {
          var HiddenValue = document.getElementById("&lt;%= MyHiddenField.ClientID %&gt;").value;
  
          //do my thing thing.....
      }
  &lt;/script&gt;
  &lt;asp:PlaceHolder ID="MyPlaceHolder" runat="server" Visible="false"&gt;
      &lt;asp:HiddenField ID="MyHiddenField" runat="server" /&gt;
  &lt;/asp:PlaceHolder&gt;
  </code></pre>
  
  <p><b>EDIT:</b>  How do I set the style for a div tag in the ascx code behind in C#?  This is the description from the code behind:  CssStyleCollection HtmlControl.Style</p>
  
  <p><b>UPDATE:</b> I replaced the asp:hiddenfield with an asp:label and I am getting an "undefined" when I display the HiddenValue variable in a alert box.  How would I resolve this.</p>
  
  <p><b>UPDATE 2:</b> I went ahead and refactored the code, I replaced the hidden field control with a text box control and set the style to "display: none;".  I also removed the JavaScript function (it was used by a CustomValidator control) and replaced it with a RequiredFieldValidator control.   </p>