无法检索隐藏字段值 [英] Trouble Retrieving Hidden Field Value
问题描述
你好, 这是我在主页上的代码背后的代码
受保护的
如果 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
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屋!