无法检索隐藏字段值 [英] Trouble Retrieving Hidden Field Value

查看:83
本文介绍了无法检索隐藏字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

这是我在主页上的代码背后的代码

受保护的
Sub Page_Load( ByVal sender As < font color ="#0000ff"size = 2>对象 ByVal e As System.EventArgs) 句柄 Me .Load
如果 HF_Country.Value = 没什么 然后
HF_Country.Value = 124
结束 如果
Page.ClientScript.RegisterClientScriptBlock( < font color ="#0000ff"size = 2> Me .GetType, " ClientScript" "< script type ='text / jscript'> function get_c(){var c = this.document.getElementByID('" & HF_Country.ClientID& "')。value;国家(c);}< / script>" False
结束 Sub

当页面加载相关的HTML时是

<
script type ='text / jscript'> function get_c(){ var c = .document .getElementByID( 'ctl00_HF_Country' )。值;国家(c);} < / script >

从上面生成的

Hello,

This is the code from my code behind on a masterpage

Protected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If HF_Country.Value = Nothing Then
HF_Country.Value = 124
End If
Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "ClientScript", "<script type='text/jscript'> function get_c() {var c = this.document.getElementByID('" & HF_Country.ClientID & "').value; Country(c);} </script>", False)
End Sub

When the page loads the relevant HTML is

<
script type='text/jscript'> function get_c() {var c = this.document.getElementByID('ctl00_HF_Country').value; Country(c);} </script>

which is generated from the above
and

< 输入 type =" hidden" 名称 =" ctl00 $ HF_Country" id =" ctl00_HF_Country" value =" 124" />

哪个来自页面作为asp:hiddenfield

当页面加载时我得到一个

Microsoft JScript运行时错误:对象不支持这个属性或方法

请指教。

谢谢

迈克尔

<input type="hidden" name="ctl00$HF_Country" id="ctl00_HF_Country" value="124" />

which is from the page as an asp:hiddenfield

When the page loads I get an

Microsoft JScript runtime error: Object doesn't support this property or method

Please advise.

Thanks

Michael

推荐答案

你写错了.document.getElementByID。将其替换为document.getElementById
you wrote this.document.getElementByID wrong. replace it with document.getElementById


这篇关于无法检索隐藏字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆