内容页面上的javascript错误 [英] javascript error on content page

查看:102
本文介绍了内容页面上的javascript错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i有问题。当我在没有母版页和内容页面的应用程序中工作时,javascript工作正常。但后来我需要在我的项目中使用mastr paga。使用母版页后,javascripts在函数调用时出错。

错误如下所示。



Microsoft JScript运行时错误:''document.getElementById(...)''为null或不是对象



我应该如何将javascript放入内容页面。



请尽快帮助。



感谢你

//

函数启用()

{

document.getElementById(''<%= txtID.ClientID%>' ')。disabled = true;

解决方案

添加母版页后,页面上元素的ID'会发生变化。您应该在浏览器中查看您的页面并查看其代码。在那里,您将为元素生成正确的ID(txtID)。在您的javascript函数中使用您页面的HTML源代码中生成的ID。


当您使用母版页右键单击IE浏览器中的页面时,您可以获得该ID非常规格式的控件(与常规id不同)在java脚本中使用该id。按照这个过程,并确保你会得到它。有任何疑问问我。







Happy Coding .......


你不能像这样指定id值

hello all,

i am having a problem.When i was working in an application without master page and content page, javascript was working finely.But later i needed to use mastr paga in my project.After using master page, javascripts is giving error on call of the function.
error is like below.

"Microsoft JScript runtime error: ''document.getElementById(...)'' is null or not an object"

how should i put the javascript in content page.

please help as soon as possible.

thanking you
//
function enable()
{
document.getElementById(''<%= txtID.ClientID%>'').disabled=true;

解决方案

When masterpage is added, the the id''s of elements on the page are changed. You should view your page in browser and watch its code. There you will have the correct ID generated for the element("txtID"). In your javascript function use the ID generated in the HTML source code of your page.


When you are working with master page right click on the page in IE browser from there you can get the id of the control in non-conventional format (unlike regular id) use that id in java script. Follow this process and try sure you will get it. Any doubts ask me.



Happy Coding.......


you cant specify the id value like this


这篇关于内容页面上的javascript错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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