如何在关闭子窗口时刷新父窗口 [英] How to refresh parent window while closing child window

查看:182
本文介绍了如何在关闭子窗口时刷新父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在datagrid里面有一个按钮。当我点击这个按钮时,它会弹出一个新窗口。

当我点击新窗口(子窗口)的关闭按钮时,父窗口(页面)应该刷新。



在父网格中,我已经为按钮aspx页面编写了代码



Hi,
I have one button inside datagrid. when i click on this button, it will open new window as popup.
when i click on close button from new window(child window),parent window(page) should refresh.

in parent grid, i have written code for button aspx page

<asp:ButtonColumn HeaderText="" ButtonType="LinkButton" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"  HeaderStyle-Width="120px"     Text="<img src='../../images/ListOfProducts.gif' width=110   border=0/>"

CommandName="ProductsList"  />





C#代码---------------





C# code---------------

protected void dgprod_ItemCommand(object Sender, DataGridCommandEventArgs e)
   {
       if (e.CommandName == "ProductsList")
       {


Response.Write("<script type='text/javascript'>window.open('Productspage.aspx?ID=" + e.Item.Cells[0].Text + "','height=80','width=1100','_blank');</script>");

       }







从儿童页面点击关闭按钮,我写了javascript




From child page while click on close button, i have written javascript

<script type ="text/javascript">

        function CloseMe() {

            window.close();
        }

推荐答案

你也可以这样做;在子关闭按钮上添加此代码



You may do this also; add this code on child close button

<asp:ImageButton ID="btnClose" runat="server" ImageUrl="images/popup/close_bttn.png" OnClick="btnReload_Click" OnClientClick="


找到( 'ChildPopupID')隐藏();返回false; / >

protected void btnReload_Click(object sender,EventArgs e)
{
//调用你要加载的控件
}
find('ChildPopupID').hide(); return false;" /> protected void btnReload_Click(object sender, EventArgs e) { //call the controls which you want to load }





同时把所有控件放在更新面板内。



希望这可以解决你的问题问题。



Also put all the controls should be inside update panel.

Hope this might solve your problem.


在window.close();之后添加以下代码行。

Add below line of code after window.close();.
window.opener.location.reload();











OR

<script>
        window.onunload = refreshParent;
        function refreshParent() {
            window.opener.location.reload();
        }
    </script>



参考: http://forums.asp.net/t/1796992.aspx [ ^ ]

这可能会有所帮助。


Refer:http://forums.asp.net/t/1796992.aspx[^]
This may help.


这篇关于如何在关闭子窗口时刷新父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆