Asp.net 在代码隐藏中获取隐藏字段
我一直在这里和其他地方寻找答案,但到目前为止还没有找到确切的方法 我在.aspx页面中对隐藏字段有以下定义:Asp.net 在代码隐藏中获取隐藏字段,asp.net,vb.net,Asp.net,Vb.net,我一直在这里和其他地方寻找答案,但到目前为止还没有找到确切的方法 我在.aspx页面中对隐藏字段有以下定义: 我在客户端的javascript函数中设置值: 函数confirmAddressChange() { if(文件类型.forms[0].hfAddressChange.valueOf==“未定义”) { var res=(确认('updatecontact address to Rich?')==true); document.forms[0].hfAddressChange.va
我在客户端的javascript函数中设置值:
函数confirmAddressChange()
{
if(文件类型.forms[0].hfAddressChange.valueOf==“未定义”)
{
var res=(确认('updatecontact address to Rich?')==true);
document.forms[0].hfAddressChange.valueOf=res;
}
}
基本上我只想设置一次值
现在我想检查代码隐藏中的值:
If hfAddressChange.Value <> String.Empty Then
Dim x As String = "Do Something here"
End If
如果hfAddressChange.Value字符串为空,则
Dim x As String=“在这里做点什么”
如果结束
然而,即使我已经验证了这个值是在js函数中设置的,当它到达我的代码后面时,它始终是一个空字符串
有人知道我到底做错了什么吗
document.forms[0].hfAddressChange.valueOf = res;
属性是value
,而不是valueOf
。(之前也不会是未定义的;只需检查!document.forms[0].hfAddressChange.value
)
属性是value
,而不是valueOf
。(之前也不会是未定义的;只需检查!document.forms[0].hfAddressChange.value
)请不要写入==true
。请确认您没有在页面加载上设置隐藏字段的值。请不要写入==true
。请确认您没有在页面加载上设置隐藏字段的值。