如何在javascript中的Wizard控件中查找控件
我有 ASP.NET 应用程序,其页面带有 ASP.NET 向导控件。该向导控件具有文本框控件。我想在 JavaScript 中访问这个文本框值。 当我尝试通过以下方式访问此文本框控件时:
var originalPrice2 = document.getElementById('<%= mytextbox.ClientID %>').value;
or
var originalPrice2 = document.getElementById('mytextbox').value;
but not getting any value .
当我启动 firebug 时,我发现引擎将 id 动态分配给文本框控件,如 "ctl00_ContentPlaceHolder1_Wizard1_mytextbox"
当我尝试使用此生成的 id 获取文本框的值时。
var originalPrice2 = document.getElementById('<%= ctl00_ContentPlaceHolder1_Wizard1_mytextbox.ClientID %>').value;
但出现异常:
The name 'ctl00_ContentPlaceHolder1_Wizard1_mytextbox' does not exist in the current context
为什么会这样?我的 html 与我解释的完全相同。
I have asp.net application having page with asp.net wizard control. this wizard control having the textbox controls. I want to access this textbox value in javascript.
where as i tried to access this text box control by this :
var originalPrice2 = document.getElementById('<%= mytextbox.ClientID %>').value;
or
var originalPrice2 = document.getElementById('mytextbox').value;
but not getting any value .
where as I started firebug I found engine dynamically allocating the id to textbox control as "ctl00_ContentPlaceHolder1_Wizard1_mytextbox"
and when i tried to get value of text box using this generated id.
var originalPrice2 = document.getElementById('<%= ctl00_ContentPlaceHolder1_Wizard1_mytextbox.ClientID %>').value;
but getting exception :
The name 'ctl00_ContentPlaceHolder1_Wizard1_mytextbox' does not exist in the current context
Why should be this? my html is exactly same what i explained.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 jQuery:
或
Try using jQuery:
OR