JScript 运行时错误: getElementById(...)' 为空或不是对象
各位高手 帮帮忙看看 怎么回事
Default.aspx 页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function open_windows_and_get_selectedinfo(openwindow, control, control2) {
var str = window.showModalDialog(openwindow, window, "dialogWidth=740px;dialogHeight=600px;center=yes;help=no;resizable=no;status=no");
if (!str)
return;
document.getElementById(control).value = str[0];
document.getElementById(control2).value = str[1];
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt_Name" runat="server"></asp:TextBox>
<input type="button" id="selectActive" runat="server" onclick="javascript:open_windows_and_get_selectedinfo('TestEdt.aspx','hhh','txt_Name')" value="..." />
<asp:HiddenField ID="hhh" runat="server"/>
</div>
</form>
</body>
</html>
TestEdt.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestEdt.aspx.cs" Inherits="TestEdt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" language="javascript">
function dbclick_return_and_close(strid, strvalue) {
//alert("执行该方法!");
var str = new Array(strid, strvalue);
window.returnValue = str;
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<a href="#" onclick="javascript:dbclick_return_and_close( '1', '<%#Eval("name") %>');">
<%# Eval("name") %></a>
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ManageSystemConnectionString %>"
SelectCommand="SELECT [Name] FROM [CollageDetailed]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
这代码的功能是 在defoult页面 点击一个按钮 弹出一窗体显示信息 然后点击信息返回 defoult 页面 功能成功了
问题是 在页面套用了模板页(里面有脚本)以后 就不好使了 显示 JScript 运行时错误: getElementById(...)' 为空或不是对象
------解决方案--------------------open_windows_and_get_selectedinfo('TestEdt.aspx','<% Response.Write(hhh.ClientID) %>','<% Response.Write(txt_Name.ClientID) %>')"
------解决方案--------------------