How can I refresh parent page when popup page is close in ASP.NET . I update the db in popup page. I list the information on parent page.

Recommended Answers

All 3 Replies

Hi arslanovski,

I hope this usefull.

ASP.Net :

Protected Sub BtnOk_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnOk.ServerClick
        Dim s As String = ""

        s = "<script>window.opener.location.reload();</script>"
        If Not ClientScript.IsClientScriptBlockRegistered("S1") Then
            ClientScript.RegisterClientScriptBlock(Me.GetType(), "S1", s)
        End If

        s = "<script>window.close();</script>"
        If Not ClientScript.IsClientScriptBlockRegistered("S2") Then
            ClientScript.RegisterClientScriptBlock(Me.GetType(), "S2", s)
        End If
    End Sub

JavaScript :

function Button1_onclick() 
{
   window.opener.location.reload();
   window.close();
}

<input id="Button1" type="button" value="button" language="javascript" onclick="return Button1_onclick()" />

Thanks,

Kusno

u can aslo use this method

In parent page:
protected void Page_Load(object sender, EventArgs e)
    {
        this.ClientScript.GetPostBackEventReference(this, string.Empty);

        if (this.IsPostBack)
        {
            string eventTarget = (this.Request["__EVENTTARGET"] == null) ? string.Empty : this.Request["__EVENTTARGET"];

            if (eventTarget == "ChildWindowPostBack")
            {
              //update work goes here
            } 
}
In child page:
ClientScript.RegisterStartupScript(this.GetType(), "msg", "window.close();window.opener.__doPostBack('ChildWindowPostBack', '');", true);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.