2014-11-03 89 views
0
public static string PopUpParentPage 
{ 
    get 
    { 
     if (HttpContext.Current.Session["PopUpParentPage"] == null) 
     { 
      return (string.Empty); 
     } 
     else 
     { 
      return (string)(HttpContext.Current.Session["PopUpParentPage"]); 
     } 
    } 
    set 
    { 
     HttpContext.Current.Session["PopUpParentPage"] = value; 
    } 
} 

我有上面的代碼,它讓我成爲彈出窗口的父代。如何在彈出頁面關閉時重新加載父頁面

而且下面是如何我在父窗口中打開從一個鏈接按鈕單擊事件彈出窗口

protected void lnkOpenPopUp_Click(object sender, ImageClickEventArgs e) 
{ 
    string strScript = "<script>fnChangeLocationPopup();</script>"; 
    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "openPopup", strScript); 
} 

這也是我如何關閉在彈出的窗口中單擊彈出頁面

上的按鈕
protected void btnClosePopUp_Click(object sender, ImageClickEventArgs e) 
    { 
    string strScript = "<script>fnChangeLocationPopup();</script>"; 
    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "closePopup", strScript); 
} 

現在我想要重新加載父頁面,以便刷新數據。如果我知道父頁面URL的值在上面的第一個代碼片段中檢索,那麼一旦彈出窗體關閉,我如何才能在btnClosePopUp_Click上刷新它?

回答

0

的Javascript:你內心功能fnChangeLocationPopup() writebelow代碼

window.location.reload(); 

代碼隱藏:

Response.Redirect(Request.RawUrl); 

這將重定向到同一頁面。

0

您可以使用下面的代碼獲取彈出頁面的Close事件。 並編寫一個代碼,使用.parent屬性重新加載父窗口,如下所示。

<script type="text/javascript"> 
     window.onbeforeunload = closePopup; 
function closePopup(){ 
window.parent.location.reload(); 
} 
</script> 

只要在上面的代碼彈出頁<head>標籤。

0

嘗試這個JavaScript

function myfunction() { 
     if (window.opener != null) { 
      opener.location.reload(true); 
      window.close(); 
     } 
    }