日期:2014-05-17  浏览次数:20960 次

子页面传值给父页面,不让父页面原有值丢失
父页面通过Button1在新窗口打开子页面zi.aspx
<tr>
   <td><asp:TextBox ID="txt1" runat="server" Width="200px" ></asp:TextBox>
    <input id="Button1" type="button" value="请选择" onclick="javascript:window.open('zi.aspx');" />
   </td>
   <td>
    <asp:textbox id="txt2" runat="server" Width="200px"></asp:textbox>
   </td>  
</tr>

子页面通过以下方法将gridview中的值传给父页面fu.aspx的txt1,txt2
protected void GVInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
               Response.Write("if(confirm('你确认要选择吗?')){opener.location.href='fu.aspx?id1=" + e.Row.Cells[2].Text.ToString() + "&id2=" + e.Row.Cells[3].Text.ToString()  +  "';self.close();}");
            }
        }

虽然子页面将值传到了父页面,但是父页面原先添加的值没有了,怎么不让父页面原有的值被清掉,最后的分数了,请大家帮帮忙,谢谢!
JavaScript ASP HTML C#

------解决方案--------------------
使用window.open()来传值,参考http://www.cnblogs.com/slyzly/articles/2799415.html