Close popup window and refresh parent window in ASP.Net from CodeBehind.

Mohammed Imtiyaz Jun 1, 2014

This tutorial will explain you how to close the popup window and refresh parent window in ASP.Net from CodeBehind.

Note: You need to add the following namespace first to run the code properly.

C#

Namespace

using System.Web.UI;

Button Click Event

protected void btnSubmit_Click(object sender, EventArgs e) {
    ClientScript.RegisterClientScriptBlock(this.GetType(), "ClosePopup", "window.close();window.opener.location.href=window.opener.location.href;", true);
}

VB.Net

Namespace

Imports System.Web.UI

Button Click Event

Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)
	ClientScript.RegisterClientScriptBlock(Me.[GetType](), "ClosePopup", "window.close();window.opener.location.href=window.opener.location.href;", True)
End Sub