【问题标题】:Refresh partial parent page on closing popup in vb.net在 vb.net 中关闭弹出窗口时刷新部分父页面
【发布时间】:2016-03-09 09:44:10
【问题描述】:

点击按钮会打开一个弹出窗口。在子窗口中我进行了一些更改,当我保存时,需要关闭弹出窗口并像单个更新面板一样刷新部分父页面。

我不想完全刷新父页面。

【问题讨论】:

  • 你为什么不能use the updatepanel
  • 在父页面 3 中存在更新面板。我只想更新一个
  • 你看过我发布的链接了吗?
  • 还有一个问题,刷新父面板的按钮在母版页内。所以我如何在 .getElementById 中管理它
  • 嘿,谢谢,我通过设置 clientIdmode=static 解决了这个问题

标签: asp.net vb.net


【解决方案1】:

您必须从弹出窗口中触发刷新目标更新面板的事件。一种方法是使用 window.opener 元素。

这是一个弹出窗口中的简单代码示例,您可以根据自己的项目进行调整。请注意,您需要将“btnTriggersUpdate”更改为给任何按钮触发更新面板刷新的 ClientID。

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

在我的示例中,这是父级中的更新面板:

<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>  

父母的 btnTriggerUpdate_Click 以证明它更新:

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

【讨论】:

    猜你喜欢
    • 2016-12-19
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 1970-01-01
    • 1970-01-01
    • 2012-07-09
    相关资源
    最近更新 更多