简体   繁体   中英

Refresh partial parent page on closing popup in vb.net

On click of button a popup window open. In the child window I made some changes and when I save, popup need to be closed and partial parent page refreshed like a single updatepanel.

I don't want complete parent page refresh.

You have to trigger the event that refreshes the target update panel from the popup. One way of doing this is using the window.opener element.

Here is a simple example of code in a popup that you can adapt for your project. Note you'll need to change 'btnTriggersUpdate' to the ClientID that is given to whatever Button triggers the Update Panel refresh.

<asp:Button runat="server" ID="btnRefreshParentUpdatePanel" OnClientClick="window.opener.document.getElementById('btnTriggersUpdate').click();" Text="Refresh Parent Update Panel" />

In my example, here is the Update Panel in the parent:

<asp:UpdatePanel ID="upnTarget" runat="server">
    <ContentTemplate>
        <asp:Label id="lblUpdatePanelLabel" runat="server" Text="Not Updated"></asp:Label>
        <asp:Button ID="btnTriggersUpdate" runat="server" Text="Refreshes Update Panel" />
    </ContentTemplate>
</asp:UpdatePanel>  

Parent's btnTriggerUpdate_Click to prove it updates:

Protected Sub btnTriggersUpdate_Click(sender As Object, e As EventArgs) Handles btnTriggersUpdate.Click
    lblUpdatePanelLabel.Text = "Updated"
End Sub 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM