首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从ajax modalpopup中更新updatepanel

从ajax modalpopup中更新updatepanel
EN

Stack Overflow用户
提问于 2014-06-28 15:49:04
回答 1查看 3.4K关注 0票数 0

我有一个带有ajax modalpopup控件的aspx页面。当我在modalpopup中点击按钮时,我需要更新页面上updatepanel中的内容(而不是modalpopup中的内容)。

这样我就可以在updatepanel中显示更改,而不需要刷新整个页面。我已经尝试在按钮单击事件的代码中使用UpdatePanel.Update()方法。但它什么也做不了。

我现在要做的是在按钮单击事件中刷新整个页面。

有没有办法更新更新面板以显示更改?

更新:下面是相关aspx页面中的代码片段。

代码语言:javascript
复制
<div style="width: 400px; height: 200px; float: right;">
            <br />
            <asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateModel="Conditional">
                <ContentTemplate>
                    <asp:Label ID="lblDate" runat="server"></asp:Label>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnGetSelectedDate" />
                </Triggers>
            </asp:UpdatePanel>                
        </div>

        <ajaxToolkit:ModalPopupExtender ID="mpeUpcomingDaysOff" runat="server" PopupControlID="panelUpcomingDaysOff" BackgroundCssClass="modalBackground" DropShadow="true" Enabled="True" TargetControlID="btnChangeUpcomingDaysoff" OkControlID="btnGetSelectedDate" CancelControlID="btnUpcomingDaysOffCancel" OnOkScript="window.top.location.reload();">
        </ajaxToolkit:ModalPopupExtender>
        <asp:Panel ID="panelUpcomingDaysOff" runat="server" Height="400" Width="700" BackColor="White" Style="border-radius: 5px">
            <div style="height: 50px; width: 700px; padding-left: 100px; font-family: Verdana; padding-top: 5px">
                <div>
                    <span style="font-weight: bold">Upcoming Daysoff for
                        <asp:Label ID="lblProviderNameDaysOff" runat="server"></asp:Label></span><br />
                    <span style="font-size: 12px">Select vacation and any other days when this service provider will not be available for online appointments.</span>
                </div>
                <div style="height: 300px; padding-left: 150px">
                    <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                        <ContentTemplate>                           
                            <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="Black"
                                Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="250px" OnPreRender="Calendar1_PreRender" Width="330px"
                                OnSelectionChanged="Calendar1_SelectionChanged" OnLoad="Calendar1_Load" BorderStyle="Solid" CellSpacing="1" NextPrevFormat="ShortMonth">
                                <DayHeaderStyle Font-Bold="True"
                                    Height="8pt" Font-Size="8pt" ForeColor="#333333" />
                                <DayStyle BackColor="#CCCCCC"></DayStyle>

                                <NextPrevStyle Font-Size="8pt" ForeColor="White" Font-Bold="True" />
                                <OtherMonthDayStyle ForeColor="#999999" />
                                <SelectedDayStyle BackColor="#333399" ForeColor="White" />

                                <TitleStyle BackColor="#333399" Font-Bold="True"
                                    Font-Size="12pt" ForeColor="White" BorderStyle="Solid" Height="12pt" />
                                <TodayDayStyle BackColor="#999999" ForeColor="White" />
                            </asp:Calendar>
                    <br />
                    <asp:Button ID="btnGetSelectedDate" runat="server" Text="OK" OnClick="btnGetSelectedDate_Click" />
                    <asp:Button ID="btnUpcomingDaysOffCancel" runat="server" Text="Cancel" />
                    </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
EN

回答 1

Stack Overflow用户

发布于 2014-06-28 19:28:56

在更新面板中,如果您希望更新,则需要将模式div的按钮声明为异步回发触发器。

代码语言:javascript
复制
<asp:UpdatePanel ID="upPanel" runat="server" UpdateModel="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Id_Of_Button_In_ModalDiv" />
    </Triggers>
    <ContentTemplate>
        ....
    </ContentTemplate>
</asp:UpdatePanel>

但是请记住,您的模式div不应该是更新面板的一部分。如果是,它将在回调后消失,因为ContentTemplate中的所有内容都将替换为来自服务器的内容。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24464787

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档