title: Accessing value of a hidden field on Masterpage from codebehind
body: <p>In a follow up to my previous <a href="https://stackoverflow.com/q/15682764/72324">question</a>, I want to get the value of the hidden input field from the child page codebehind.   </p>
  
  <p>I tried <code>HtmlInputHidden hdnID = (HtmlInputHidden)Page.Master.FindControl("ctl00_hdnField");</code> but I get a "null" value.  </p>
  
  <p><img src="https://i.stack.imgur.com/2H0T6.png" alt="enter image description here"></p>
  
  <p>A snippet of the Masterpage is:  </p>
  
  <pre><code>&lt;head runat="server"&gt;
      &lt;title&gt;
          &lt;asp:ContentPlaceHolder ID="TitleContent" runat="server"&gt;&lt;/asp:ContentPlaceHolder&gt;
          &lt;asp:Literal ID="Literal2" runat="server" Text=" : Logistics Management" /&gt;
      &lt;/title&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  
      &lt;link href="~/css/styles.css" rel="stylesheet" type="text/css" /&gt;
  
      &lt;asp:ContentPlaceHolder ID="ScriptCssContent" runat="server"&gt;
      &lt;/asp:ContentPlaceHolder&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form id="form1" runat="server"&gt;
      ......
      ......
      ......
          &lt;div id="container"&gt;
          ....
          ....
          ....
                  &lt;div id="content" style="z-index:0;"&gt;
                  &lt;asp:HiddenField ID="hdnField" runat="server" Value=""/&gt;
                  ....
                  ....
                  ....
                          &lt;asp:ContentPlaceHolder ID="MainContent" runat="server"&gt;
  
                          &lt;/asp:ContentPlaceHolder&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>On my Child aspx page, I have this javascript block:  </p>
  
  <pre><code>window.onload = function() {
      var newDate = new Date();
      var hidField = document.getElementById("ctl00_hdnField");
  
      if (hidField != null)
          hidField.value = newDate.toLocaleString();
  }
  </code></pre>
  
  <p>When I "Add Watch" to </p>
  
  <blockquote>
    <p>document.getElementById("ctl00_hdnField")    </p>
  </blockquote>
  
  <p>the value is correct.  </p>
  
  <p><strong>Question:</strong> How would I access the value inside hdnField control, from codebehind?</p>