Tag: hidden field

从代码隐藏访问Masterpage上的隐藏字段的值

在我之前的问题的后续跟进中,我想从子页面代码隐藏中获取隐藏输入字段的值。 我试过HtmlInputHidden hdnID = (HtmlInputHidden)Page.Master.FindControl(“ctl00_hdnField”); 但我得到一个“空”值。 Masterpage的片段是: …… …… …… …. …. …. …. …. …. 在我的Child aspx页面上,我有这个javascript块: window.onload = function() { var newDate = new Date(); var hidField = document.getElementById(“ctl00_hdnField”); if (hidField != null) hidField.value = newDate.toLocaleString(); } 当我“添加观察”时 的document.getElementById( “ctl00_hdnField”) 价值是正确的。 问题:如何从代码隐藏中访问hdnField控件中的值?