How can I update a c# parent page from a pop-up page without a full refresh
Does anyone kno开发者_运维知识库w 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?
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.
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.
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.
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
精彩评论