Microsoft JScript运行时错误:'document.all.TextBox2'为null或不是对象 [英] Microsoft JScript runtime error: 'document.all.TextBox2' is null or not an object
本文介绍了Microsoft JScript运行时错误:'document.all.TextBox2'为null或不是对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i face
Microsoft JScript运行时错误:'document.all.TextBox2'在以下脚本中为null或不是对象
< script 语言 = javascript >
函数showDirectory(){
document.all.TextBox2。 value = window.showModalDialog( browseDirectory.aspx,' jain', dialogHeight:560px; dialogWidth:360px; edge:Raised; center:是;帮助:是;可调整大小:是;状态:否;);
return false ;
}
< / script >
这种形式的
我使用脚本管理器,因为该页面必须我使用infragistic控制。
如何解决这个问题..
任何人帮助我。
解决方案
document.all
是一个非标准的扩展程序,甚至Microsoft删除来自IE浏览器。
所以不要使用它!使用document.getElementById('TextBox2')
。它是标准的并且得到每个浏览器的支持...
从评论中可以明显看出HTML的来源是一个ASP.NET页面。
ASP.NET根据您输入的内容创建自己的ID - 以确保页面中的唯一ID。
有关详细信息,您可能会看到 INamingContainer [ ^ ]。
这意味着您提供的ID(TextBox2)仅对服务器端有效。要在客户端上访问同一个对象,请像这样编写JavaScript
document .getElementById(' <%= TextBox2.ClientID%>')
hi,
i face
"Microsoft JScript runtime error: 'document.all.TextBox2' is null or not an object"
in following script
<script language="javascript">
function showDirectory() {
document.all.TextBox2.value = window.showModalDialog("browseDirectory.aspx", 'jain', "dialogHeight: 560px; dialogWidth: 360px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: No;");
return false;
}
</script>
in this form i use script manager, that is must for that page because of i use infragistic control.
how to solve this problem..
anybody help to me.
解决方案
document.all
is a non-standard extension that even Microsoft removes it from IE.
So don't use it! Usedocument.getElementById('TextBox2')
. It's standard and supported by every browser...
It became obvious - from comments - that the source of the HTML is an ASP.NET page.
ASP.NET creates it's own ids - based on what you entered - to ensure unique id fro page.
For details you may see INamingContainer[^].
It means that the id you give (TextBox2) is valid only for server-side. To access the very same object on client write your JavaScript like this
document.getElementById('<%=TextBox2.ClientID%>')
这篇关于Microsoft JScript运行时错误:'document.all.TextBox2'为null或不是对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文