ASP.NET#使用母版时,如果要使用js中的getElementById()方法取得某个内容页的元素时要注意的问题
2013-09-02 01:29
791 查看
当使用母版,要使用js中的getElementById()方法取得某个内容页的元素时,所选取的id并不是母版中内容页的id,而是在设计内容页时设定的id
例子:
母版页:
内容页:
例子:
母版页:
...... <head runat="server"> <title>无标题页</title> <link href="../css/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" language="javascript"> function fff() { var text = document.getElementById("huifu1");//要取得内容页的元素 if (text != null) { text.focus(); } } </script> </head> <body style=" color:Black"> <form id="form1" runat="server"> <div id="outer"> <div id="inner"> <div> <uc1:liuyan ID="liuyan1" runat="server" /> </div> <br /> <br /> <uc2:huifu ID="huifu1" runat="server" />//要取得的元素应该是在该内容页面中 </div> </div> </form> </body> </html>
内容页:
<table style="width:650px; height:300px" id="huifu1"> ... </table>
相关文章推荐
- asp.net中使用getElementById的注意点
- 解决模板页使用的情况下,在内容页中使用 document.getElementById找不到控件的方法
- ASP.NET 2.0 创建母版页导致js出现“ 'document.getElementById(...)' 为空或不是对象”错误
- (转载)如何用JS获取ASP.net中的textbox的值 js获不到text值,【asp.net getElementById用法】
- ASP.NET 2.0 创建母版页导致js出现“ 'document.getElementById(...)' 为空或不是对象”错误《转》
- document.getElementById("idName")用js方法获取元素,则设定风格属性的方法为
- IE8、IE7、IE6中使用getElementById需要注意的问题
- ASP.NET 创建母版页导致js出现“ 'document.getElementById(...)' 为空或不是对象”错误
- ASP.NET 2.0 创建母版页导致js出现“ 'document.getElementById(...)' 为空或不是对象”错误
- 在ASP.net中使用javascript的document.getElementById属性
- asp.net在使用母版页的内容页面中动态加载css和js文件的方法
- html dom中要查找希望操作的元素使用的方法:getElementById()和getElementsByTagName()的区别
- ASP .Net 2.0 FindControl getElementById 使用
- JS中获取元素使用getElementByID()、getElementsByName()、getElementsByTagName()的用法和区别
- ASP.NET母版与内容页相对路径的问题
- 常用的4种获取元素方法的区别, getElementById, ..ClassName, ..TagName, .Name
- getElementById 不能取得visible=false 的控件解决方法
- ASP.net 让窗口WEB打开后,弹出一个选择窗口供应选择,注意Page_Load顺序,JS产生的找不到对象的问题
- document.getElementById()方法简写【js技巧】
- asp.net mvc使用的心得和问题的解决方法(陆续更新ing)