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