两个updatePanels和popup扩展程序,在回发后不应该消失

时间:2012-02-22 15:42:40

标签: c# asp.net updatepanel modalpopupextender

在我的MasterPage我有2个面板周围的更新面板。其中两个包含“详细信息视图”控件和一些按钮。

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

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

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

我应该使用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>

我希望我描述得很好。对不起因为我的弱英语和一些波兰语的代码:)

1 个答案:

答案 0 :(得分:0)

正如我应该在开始时做的那样我在空白页面上做了这个例子并尝试了其他的东西.. 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>

如此简单......我认为它更大:/