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

  • 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>");
    }