子窗口是这样弹出来的
window.showModalDialog("khdm_xz.aspx",null, "dialogWidth:580px;dialogHeight:490px;help:no;status:no;scroll:no;");子窗口中有一GridView,想通过双击某一行,将该行的三个cell值回传到父窗口,同时关闭子窗口。
window.showModalDialog("khdm_xz.aspx",null, "dialogWidth:580px;dialogHeight:490px;help:no;status:no;scroll:no;");子窗口中有一GridView,想通过双击某一行,将该行的三个cell值回传到父窗口,同时关闭子窗口。
事件:
window.returnValue=value1+","+value2+","+value3;
关闭窗口
父窗口里
cc=window.showModalDialog("khdm_xz.aspx",...........)
alert(cc);//这里的值应该是上面设置的returnValue;
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
row.Attributes.Add("onclick", string.Format("javascript:window.parent.document.all.TextBox1.value=row.Cells[0].Text; "));
}
}
base.Render(writer);
}这里提示row没定义
现在不知道怎么样才能取到值再回传回去。
{
var result=window.showModalDialog("khdm_xz.aspx",null, "dialogWidth:580px;dialogHeight:490px;help:no;status:no;scroll:no;");
document.getElementById("txt_id").value=result.split(",")[0];
document.getElementById("txt_name").value=result.split(",")[1];
document.getElementById("txt_pwd").value=result.split(",")[2];
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt_id" runat="server" ></asp:TextBox>
<asp:TextBox ID="txt_name" runat="server" ></asp:TextBox>
<asp:TextBox ID="txt_pwd" runat="server" ></asp:TextBox>
<br />
<asp:Button ID="btnPop" runat="server" Text="PoPWindows" OnClientClick ="Pop()" /> </div>
</form>
</body>
</html>
khdm_xz.aspx function cc(infor_id,infor_name,infor_psw)
{
window.returnValue= infor_id+","+infor_name+","+infor_psw;
window.close();
}
</script>
<div>
<asp:GridView ID="gvshow" runat="server" BackColor="White" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
onrowdatabound="gvshow_RowDataBound" >
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</div>
</form>
</body>
</html>
protected void gvshow_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "cc('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "','" + e.Row.Cells[2].Text + "')");
}
}
http://topic.csdn.net/u/20091012/16/9a082f7b-97a4-4475-9d7e-b241fed6df8a.html
刷新父窗体