问题描述
大家好,
我在ASP.NET项目中使用Javascript,
Javascript代码在单独的文件中,在asp.net页面中,我这样写:
Hi guys,
I am using Javascript in ASP.NET project,
Javascript code is in separate file and in asp.net page i write that:
<script type="text/javascript" src="js/myfile_settings.js"></script>
<div id="diTextArea">
<script type="text/javascript" >
initiate(window.document);
</script>
</div>
ASP.NET页是母版页内的内容页
js文件中的方法用于在div控件中注入或呈现html代码.
当我运行项目时,出现此错误:
我制作了一个小项目,并使用了js文件,相同的html代码和母版页,并且运行成功.
但是在我的大项目中,它无法成功运行.
两个项目,相同的js文件和html代码之间没有区别,但是一个项目有很多页面,另一个项目是一个页面.
js文件具有以下方法:
ASP.NET page is content page inside master page
method in js file is used to inject or render html code within the div control.
When i run the project that error appear:
I make small project and used the js file and the same html code and master page and it run successfully.
but in my big project it is not run successfully.
no difference between two project, the same js file and html code but one has many pages and the other is one.
js file has this method:
page.getElementById("diTextArea").innerHTML=html_code;
真的很累...
realy i tired...
推荐答案
<system.web>
<pages clientidmode="Static"></pages>
</system.web>
这样asp.net不会弄乱您的控件ID!
祝你好运
that way asp.net will not mess with your control ids!
Goodluck
这篇关于getElementById(...)为null或不是对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!