1、父窗体:
<script type="text/javascript">
function XuanZeContract()
{
window.showModalDialog('子窗体.aspx','newwindow','height=300,width=500,top='+(screen.AvailHeight-300)/2+',left='+(screen.AvailWidth-300)/2+',toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}
父窗体后台取值:
TextBox1.Text = Request.QueryString["id"];
html代码:
<input id="Button3" type="button" value="选择" onclick="XuanZeContract()" />
2、子窗体后台双击选择:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//鼠标双击事件
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onDblClick", "javascript:top.location.href='父窗体.aspx?id=" + e.Row.Cells[1].Text.ToString() + "';window.close();");
}
}
3、父窗体打开子窗体后 双击选择某行值后没有跳转到父窗体,而是重新起了一页:父窗体.aspx?id=xxxxx
怎样才能让它到父窗口而不是重新起一页呢?
正确代码:
<script type="text/javascript">
function XuanZeContract()
{
window.open('子窗体.aspx','newwindow','height=300,width=500,top='+(screen.AvailHeight-300)/2+',left='+(screen.AvailWidth-300)/2+',toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}
e.Row.Attributes.Add("onDblClick", "javascript:opener.location.href='父窗体.aspx?id=" + e.Row.Cells[1].Text.ToString() + "';window.close();");