首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

有关JS父页和子页有关问题

2012-08-25 
求助:有关JS父页和子页问题父页代码:HTML codescript typetext/javascriptfunction manage() {var hd

求助:有关JS父页和子页问题
父页代码:

HTML code
<script type="text/javascript"  >        function manage() {            var hdc = window.open("detail.aspx", "NewWindow", "height=200, width=400, top=400,left=900 toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");        }    </script><asp:TextBox ID="txtpunit" class="text-input small-input" runat="server" ></asp:TextBox><img alt="detail" src="Images/png/link.png" onclick="manage()"  height="16px" width="16px" />


子夜代码:用的gridview,取一个单元格的值,传给父页

C# code
 string name = e.Row.Cells[1].Text.Trim(); e.Row.Attributes.Add("onclick ", " window.opener.document.getElementById('txtpunit').value="+name+ ";window.opener=null;window.close();");


取值这些没问题,就是从子页传不到父页去,TextBox里面取不了值。。该如何解决?

[解决办法]
e.Row.Attributes.Add("onclick ", " window.opener.document.getElementById('txtpunit').value='"+name+ "';window.opener=null;window.close();");
非数字要加引号。

另外window.opener只能用在window.open打开的子页面中,

热点排行