Ralph Lavelle
Ralph Lavelle

Reputation: 5769

How can I update a c# parent page from a pop-up page without a full refresh

Does anyone know how I can reload an UpdatePanel on my parent C# page from an action on my pop-up page WITHOUT refreshing the entire parent page. My parent page doesn't retain its state in the Url, so the user may have expanded a div here, refreshed a list there, and that parent page state needs to be preserved. All that needs to happen is that an UpdatePanel containing a GridView of 'DomainObjects.Incident' should update/refresh when the user has added a new incident in the pop-up.

Is there a way to wire up events between two different asp.net pages? Or should I be using javascript?

Upvotes: 3

Views: 3811

Answers (4)

dhinesh
dhinesh

Reputation: 4764

If there is a chance to use the RadWindow(telerik), then the communication is possible between the parent and the child page.

see the demo http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx

Upvotes: 0

Zachary
Zachary

Reputation: 6532

You can refresh an UpdatePanel by calling:

__doPostBack('<UpdatePanel ID>', '');

If you want to do this from the child page, you should be able to wrap the call up in a function and call it via JavaScript.

Example:

// Parent Page Refresh Function
function Refresh()
{
    __doPostBack('UpdatePanel1', '');
}

//Child Page Trigger
<input type="button" id="button1" onclick="window.opener.Refresh()" value="Refresh Parent" />

You should probably make sure the parent is still open before calling Refresh() by checking "window.opener.closed".

I've not tested this code, so might have a type'o.

Upvotes: 1

CRice
CRice

Reputation: 12567

Have a look at window.opener

Reference parent window document

JQuery - Write to opener window

My first thought is communicate to the parent window to perform the refresh using javascript, you could see what javascript your update panel calls via the page source and use the same.

Upvotes: 0

ulty4life
ulty4life

Reputation: 3012

The only way to do this completely managed only by .net code is if you use something like the AjaxControlToolkit to make your popup a modal div in the main page.

Otherwise, you could use javascript in the child and parent page to trigger some postback/callback in the parent page. You can set the postback/callback event as a trigger of your update panel.

Upvotes: 3

Related Questions