How to refresh parent window while closing the pop up window in C#


In this article I am going to explain you, how to refresh parent window while closing the pop up window using C#. This is one of the common query I used to see in .NET forums. To refresh the parent page here I have used JavaScript.

How to refresh parent window while closing the pop up window in C#



Below is the combination of C# and JavaScript code to refresh parent page while closing the pop window.

First copy below code in the .aspx page you are opening the pop up window, this is a simple JavaScript. Add this Script after Head tag in your HTML page.


function Submitted()
{
__doPostBack('Submit','');
location.reload();
}



Below code should be copied in your page_load event of the page you are opening the pop up,


if (IsPostBack)
{
string arg = Request.Form["__EVENTTARGET"];
string val = Request.Form["__EVENTARGUMENT"];

if (arg == "Submit")
{
//Code to populate/refresh the control
}


And finally in your popup window submit/close button click event write below code,


protected void btnSubmit_Click(object sender, EventArgs e)
{
Response.Write("<script>self.close();opener.Submitted();</script>");

}


Please post all your dobts related to this article.


Article by Asheej T K
Thanks and Regards Asheej T K Dotnet Galaxy

Follow Asheej T K or read 33 articles authored by Asheej T K

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: