两个更新面板和弹出式扩展程序,回发后不应消失

本文关键字:程序 消失 扩展 弹出式 两个 更新 | 更新日期: 2023-09-27 18:25:31

在我的MasterPage上,我有两个更新面板,它们被面板包围。其中两个包含"详细信息视图"控件和一些按钮。

另一方面,我有一个UpdatePanel,它包含图像按钮和链接按钮。

我的想法是从数据库中获取消息(2种),并将它们显示在页面上。当用户单击按钮(LinkButtonImageButton)时,他或她会看到一个"弹出控件"。在弹出控件上,他或她可以看到消息的详细信息,如果需要,可以取消或批准。

这就是我被卡住的地方。如果我从UpdatePanels中删除ImageButtons,我将无法在没有完全回发的情况下刷新它们。

如果我在UpdatePanelImageButtons中有"弹出扩展",但当我点击"弹出面板"中的按钮时,它会消失(没有完整的回发,它只是消失),它应该只更改DetailsView页面。

我该如何让它发挥作用?

提前感谢!

(我需要这个解决方案,因为我想使用计时器来刷新LinkButtons

这是我的代码:

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        //here im pulling data from database and binding it with 'details view' controls, its not big deal so i think i don't have to show it?
        wyswietl_powiadomienia_o_wydarzeniach();
        wyswietl_ilosc_zaproszen_do_przyjaciol();
        wyswietl_ilosc_nieodczytanych_wiadomosci();
    }
    catch (Exception)
    {
    }
}

protected void ButtonWczesniej_Click(object sender, EventArgs e)
{
    DetailsViewEventsRequests.PageIndex = DetailsViewEventsRequests.PageIndex - 1;
    ButtonDalej.Enabled = true;
    wyswietl_powiadomienia_o_wydarzeniach();
}
protected void ButtonDalej_Click(object sender, EventArgs e)
{
    // 
    DetailsViewEventsRequests.PageIndex = DetailsViewEventsRequests.PageIndex + 1;
    ButtonWczesniej.Enabled = true;
    wyswietl_powiadomienia_o_wydarzeniach();
}
protected void ButtonInvLeft_Click(object sender, EventArgs e)
{
    DetailsViewIfFriends.PageIndex = DetailsViewIfFriends.PageIndex - 1;
}
protected void ButtonInvRight_Click(object sender, EventArgs e)
{
    DetailsViewIfFriends.PageIndex = DetailsViewIfFriends.PageIndex + 1;
}

我的aspx:(只有一个更新面板有详细信息,因为第二个非常相似)

<div id="NotifyAreaWhite">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div id="NotifyAreaDiv">
                <div id="NotifyDivMail">
                    <div id="NotifyLeftMSG"><asp:ImageButton ID="ImageButtonNotifyMsg" runat="server"  
                            ImageUrl="~/images/msg.png" PostBackUrl="~/wiadomosci.aspx" 
                            ToolTip="Wyslij wiadomosc" /></div>
                    <div class="NotifyRight"> <asp:LinkButton ID="LabelNotifyMsgNo" runat="server"  Text="0" Font-Size="Large" PostBackUrl="~/wiadomosci.aspx"/></div>
                </div>
                <div class="NotifyDiv">
                <div id="NotifyLeftFrend" class="NotifyLeft"> <asp:ImageButton ID="ImageButtonNotifyFrends" runat="server" 
                        ImageUrl="~/images/friends.png" 
                        ToolTip="Zaproszenia od znajomych." /></div>
                <div id="NotifyRightFrend" class="NotifyRight"><asp:LinkButton ID="LabelNotifyFrendsNo" runat="server" Text="0" Font-Size="Large"/></div>
                </div>
                <div class="NotifyDiv">
                <div id="NotifyLeftWyd" class="NotifyLeft"> <asp:ImageButton ID="ImageButtonWydarzenia" runat="server" ImageUrl="~/images/event.png" ToolTip="Zaproszenia do wydarzen." /></div>
                <div id="NotifyRightWyd" class="NotifyRight"> <asp:LinkButton ID="LabelNotifyEventsNo" runat="server" Text="0" Font-Size="Large"/></div>
                </div>
                </div>
                     <asp:ModalPopupExtender ID="PanelZaproszeniaEventy_ModalPopupExtender" 
                        runat="server"  Enabled="true" OkControlID="ButtonZamknijOkno" CancelControlID="ButtonZamknijOkno"
                        TargetControlID="ImageButtonWydarzenia" PopupControlID="PanelZaproszeniaEventy"
                        BackgroundCssClass="NotifyPageTloClass"/> //extender showing Panel
                     <asp:ModalPopupExtender ID="PanelZaproszeniaEventy_ModalPopupExtenderCyfra" 
                        runat="server"  Enabled="true" OkControlID="ButtonZamknijOkno" CancelControlID="ButtonZamknijOkno"
                        TargetControlID="LabelNotifyEventsNo" PopupControlID="PanelZaproszeniaEventy"
                        BackgroundCssClass="NotifyPageTloClass"/>
                      <asp:ModalPopupExtender ID="PanelProsbyOznajomosc_ModalPopupExtender" 
                        runat="server"  Enabled="true" OkControlID="ButtonFrendCloseNotifier" CancelControlID="ButtonFrendCloseNotifier"
                        TargetControlID="ImageButtonNotifyFrends" PopupControlID="PanelProsbyOznajomosc"
                        BackgroundCssClass="NotifyPageTloClass"/>
                      <asp:ModalPopupExtender ID="PanelProsbyOznajomosc_ModalPopupExtenderCyfra" 
                        runat="server"  Enabled="true" OkControlID="ButtonFrendCloseNotifier" CancelControlID="ButtonFrendCloseNotifier"
                        TargetControlID="LabelNotifyFrendsNo" PopupControlID="PanelProsbyOznajomosc"
                        BackgroundCssClass="NotifyPageTloClass"/>
          </ContentTemplate>
    </asp:UpdatePanel>
</div>
<asp:Panel ID="PanelZaproszeniaEventy" runat="server" Width="318px" CssClass="NotifyWydTlo" >
     <asp:UpdatePanel ID="UpdatePanelZaproszeniaEventy" runat="server" RenderMode="Block">
        <ContentTemplate>
                    <asp:DetailsView ID="DetailsViewEventsRequests" runat="server" DataKeyNames="Charakterystyka" AutoGenerateRows="False" Height="17px" Width="313px" HorizontalAlign="Center" onitemcreated="DetailsViewEventsRequests_ItemCreated">
                        <Fields>
                            <asp:BoundField DataField="UserName" HeaderText="Zalozyciel" SortExpression="Nazwisko" />
                            <asp:BoundField DataField="Miasto" HeaderText="Gdzie?" SortExpression="Miasto" />
                            <asp:BoundField DataField="Data_ZalozeniaWydarzenia" HeaderText="Data wyslania" SortExpression="Miasto" />
                        </Fields>
                        <FooterTemplate>
                        </FooterTemplate>
                        <HeaderTemplate>
                            <div>
                                <div style="float:left;">
                                   <asp:Label ID="LabelNazwaWydarzenia" runat="server"  
                                      Text='<%# Eval("Nazwa_Wydarzenia") %>'></asp:Label>
                                </div>
                                <div style="float:right; margin-left:5px;">
                                   <asp:Button ID="ButtonZobacz" runat="server"  CssClass="myButton" Text="Zobacz Wydarzenie" Font-Size="X-Small" Width="150px" ClientIDMode="AutoID" OnClick="ButtonZobacz_click" UseSubmitBehavior="True"/>
                                </div>
                            </div>
                        </HeaderTemplate>
                        <EmptyDataTemplate>
                            <table id="Table1" runat="server" style="border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px; color:#FF5041; margin-left:auto; margin-right:auto;">
                                <tr>
                                   <td>Nie masz zadnych zaproszen.</td>
                                </tr>
                            </table>
                        </EmptyDataTemplate>
                    </asp:DetailsView>
            <table style="margin-left:auto; margin-right:auto;">
                <tr>
                    <td>
                        <asp:Button ID="ButtonWczesniej"  Width="69px" Height="41px" runat="server" Text="<<" OnClick="ButtonWczesniej_Click" CssClass="myButton" /></td> //button previous msg
                    <td>
                      <asp:Button ID="ButtonDalej" Width="69px" Height="41px" runat="server" Text=">>"  ///button next msg
                            OnClick="ButtonDalej_Click" CssClass="myButton"/></td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    <div style="margin-left:auto; margin-right:auto; width: 112px;">
        <asp:Button CssClass="myButton" ID="ButtonZamknijOkno"  Width="100%"  //button closing popup
        Height="41px" runat="server" Text="ZAMKNIJ"/>
    </div>
</asp:Panel>

我希望我描述得很好。对不起,我的英语很弱,代码中有一些波兰语单词:)

两个更新面板和弹出式扩展程序,回发后不应消失

正如我一开始应该做的那样,我在空页面上做了这个例子,并尝试了其他方法。。mode="Conditional"成功了。

我应该先给出那个代码,而不是那个长代码:)

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        <asp:HyperLink ID="HyperLinkPanelOn" runat="server">click here to show popup</asp:HyperLink>
            <asp:ModalPopupExtender ID="PanelZaproszeniaEventy_ModalPopupExtenderCyfra" 
            runat="server"  Enabled="true" OkControlID="ButtonClose" CancelControlID="ButtonClose"
            TargetControlID="HyperLinkPanelOn" PopupControlID="Panel1" BackgroundCssClass="NotifyPageTloClass" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Panel ID="Panel1" runat="server">
        <asp:UpdatePanel ID="UpdatePanelPopUp" runat="server">
        <ContentTemplate>
            <asp:Button runat="server" Text="postback" />
            <asp:Button runat="server" Text="postback" />
         </ContentTemplate>
        </asp:UpdatePanel>
        <asp:Button ID="ButtonClose" runat="server" Text="Zamknij" />
    </asp:Panel>

太简单了。。我认为它是更大的东西:/