开发者

How to reload a partial view in a parent page on child page post

开发者 https://www.devze.com 2023-01-30 12:15 出处:网络
Th开发者_开发百科e parent page contains 3 partial views in it Index_Top, Index_Left and Index_main. On hitting a button in Index_Left a new window opens using window.open(\"MyController/ChildPage\") f

Th开发者_开发百科e parent page contains 3 partial views in it Index_Top, Index_Left and Index_main. On hitting a button in Index_Left a new window opens using window.open("MyController/ChildPage") function in javascript.

Now I should reload only the Index_Left on the parent page on the child page submit.

Can any one help me how can I do it?

I tried using like below. $.post("/MyController/ChildPage/", { }, function (result) { if (result.Message == "OK") { window.opener.location.reload(true); window.close(); } }, "json");

But, it is reloading the entire parent page. But, I want to reload only a Index_Left parital page.


Inside the main page define a javascript function:

function reloadLeftPanel() {
    // Do an AJAX request and reload the left panel like for example:
    $('#leftPanel').load('<%= Url.Action("MyController", "ChildPage") %>');
}

And in the popup window call this function whenever you want to reload the left panel on the opener page:

window.opener.reloadLeftPanel();
0

精彩评论

暂无评论...
验证码 换一张
取 消