Is there a way to refresh the parent page once the popup page has been closed?

public static string GetParentPopup
{
    get
    {
        if (HttpContext.Current.Session["ParentPopup"] == null)
        {
           return (string.Empty);
        }
        else
        {
            return (string)(HttpContext.Current.Session["ParentPopup"]);
        }
    }
    set
    {
        HttpContext.Current.Session["ParentPopup"] = value;
    }
}

The code snippet above retrieves the parent of a popup window.

Below is how I trigger the pop-up window from a link button click event in the parent window:

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

This is also how I close the popup window by clicking a button on the popup page:

protected void ClosePopup_Click(object sender, ImageClickEventArgs e)
  {
    string script = "<script>ChangeLocationPopup();</script>";
    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "closePopup", script);
}

Now, I want to reload the parent page to refresh the data. If I know the URL of the parent page as retrieved in the first code snippet above, how can I ensure it gets refreshed upon closing the popup form using btnClosePopUp_Click?

Answer №1

Javascript: in your function fnChangeLocationPopup(), include the following code

 window.location.reload();

CodeBehind:

Response.Redirect(Request.RawUrl);

this action will direct you to the current page.

Answer №2

If you want to capture the Close event of a Popup page, use the code provided below. Additionally, include a snippet that reloads the parent window using the .parent property as demonstrated.

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

Incorporate the above code snippet within the <head> tag of your Popup page.

Answer №3

give this javascript a shot

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve information (array of key-value pairs) passed to controller's function using AJAX

When attempting to POST a form in AJAX, one of the parameters I am sending is an associative array. The request appears to be successful and the parameters are being properly sent. Here is the AJAX call: var fieldsEdited = [{"Key":1,"Values":["value1"]} ...

The Xrm.Navigation function has not been defined

When attempting to open a modal dialog box, I used the following code: var addParams = "entityid=" + Xrm.Page.data.entity.getId() + "&entityName=" + Xrm.Page.data.entity.getEntityName(); var webresourceurl = "/webresources/pdfflr_selectorpage.html?Dat ...

The required validator in Mongoose is not being triggered by the function

I'm trying to use a function as a validator in a mongoose schema, but it doesn't seem to work if I leave the field empty. The documentation states: Validators are not run on undefined values. The only exception is the required validator. You ...

"Enhance gaming experience by loading game sources using jQuery Ajax and displaying them as

I am currently working with a website system that utilizes ajax to load content without refreshing pages. On one of my pages, I have multiple HTML5 game links being loaded via ajax JSON. When a game is clicked on, it opens as a pop-up displaying the game s ...

The jQuery toggleClass() function is not being applied successfully to content that is dynamically generated from

I've created an awesome collection of CSS-generated cards containing icons and text with a cool animation that expands upon tapping to reveal more icons and options. I carefully crafted the list to look and behave exactly how I wanted it to. But now, ...

Please ensure the public_id parameter is included and provide the necessary value for the imageId when working with Cloudinary

I am in the process of developing a website where users can share insights and comments on novels they have read. Users have the option to include images of the novel with their posts or not. If an image is included, the post schema requires attributes im ...

Is there a way to extract and store the numerical values from a string in Selenium IDE?

Is there a way to extract the confirmation number 135224 from the example below for use on another website? store text | xpath=//b[contains(., 'Authorization Request - Confirmation Number : 135224')] | string Unfortunately, I'm encounterin ...

Working with Three.js: Utilizing the SpotLight and dat.gui

I have implemented a SpotLight in my scene along with an OctahedronGeometry as a visual aid for the user. The SpotLight can be moved using transformControls by selecting it, which is working properly. However, the issue arises when I try to edit the setti ...

Fetching images from the web root using asp.net core and React frontend

My current setup consists of an asp.net core web project integrated with React, along with a separate project serving as the API. The API is responsible for saving images to a specific folder named Images in the content root directory. Now, my challenge ...

The process of uploading data onto a map using jquery is quite inconsistent in its functionality

HTML Instructions: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,initial-scale=1"> <me ...

What is the technique for showing text in two different colors through a script?

What is the method to alternate text colors using a script? Display the text in color #ccc for 1 second, then switch to color #000 for 1 second, and finally return to color #ccc for 1 second (repeating in a loop). ...

The absence of parameters in the Express.js middleware object

const application = express(); let routerInstance = require('express').Router({mergeParams: true}); const payloadMiddlewareFunction = (request, response, next) => { console.log('A:', request.params); const {params, query} = reque ...

Update the appearance of buttons using AngularJS

I am trying to change the style of 3 buttons when they are clicked. I am not sure if angular has built-in functions like ng-class or ng-click that can help me achieve this. I have tried implementing them but it doesn't seem to work. <button class= ...

Execute a refresh command on a JQuery function in order to update the selection picker

Below is the HTML code I have created to allow for multiple options to be selected with live search capabilities. My knowledge of jQuery is limited, but I have included a code snippet to refresh the selections if more than one option is chosen. < ...

What is the best way to swap out elements within an array?

A server-loaded array with type FilterModel[] is depicted below: export type FilterModel = { title: string; type: FilterType; collection: FilterList; }; export type FilterList = FilterListItem[]; export type FilterListItem = { id: number | ...

There seems to be an issue with the code as it is encountering an unhandled

Here is an example of code that is not functioning properly when using an MS Access database: protected void Page_Load(object sender, EventArgs e) { BindData(); } private void BindData() { OleDbConnection conn = new OleDbConnection(); conn.Co ...

Callback error in Ajax request

$(this).find(':submit').attr('disabled',true); $.ajax( { url:'/enviarSugerenciaMessageBoard', cache: false, type: 'POST', data: $(this).serialize(), ...

What kind of composition does React use for a component's children?

I have been using the type "any" to refer to the children of my components, but after updating my deploy I received an error saying that "any" is not a valid type. What type should I use for the children in my Section component below? import { ReactEleme ...

Designing a website with a 4x4 layout grid

How can I create a webpage with a 4x4 grid that changes colors in each square when clicked on? Appreciate any advice! ...

Issue encountered in Babel version 6 with the transform-es2015-classes plugin in loose mode, causing a SyntaxError when using async/await

After updating to the latest version of Babel v6, I encountered an issue with the transform-es2015-classes plugin in loose mode (https://github.com/bkonkle/babel-preset-es2015-loose/blob/master/index.js#L8) causing problems with async/await functions. Here ...