1
我一直在寻找答案在这里和其他地方,但到目前为止还没有找到如何做到这一点。隐藏字段在代码背后
我有一个隐藏字段的定义如下在我的.aspx页面中:
<asp:HiddenField ID="hfAddressChange" runat="server" />
我在JavaScript函数设置的值在客户端上:
function confirmAddressChange()
{
if (typeof document.forms[0].hfAddressChange.valueOf ==="undefined")
{
var res = (confirm('"Update Contact Addresses to Rich?"')==true);
document.forms[0].hfAddressChange.valueOf = res;
}
}
基本上我只是想设置一次值。
现在我想在后面的代码来检查值:
If hfAddressChange.Value <> String.Empty Then
Dim x As String = "Do Something here"
End If
然而,尽管我已经验证该值在JS功能被设置,它始终是一个空字符串时,它得到到我的代码背后。
任何人看到我在做什么错了?
请不要写'== true'。 – Ryan
请确认您未在页面加载中设置隐藏字段的值。 – cbillowes