多个UpdatePanel回发触发其他UpdatePanel的updateprogress动画

时间:2012-06-13 04:14:15

标签: asp.net webforms updatepanel updatepanel-progressbar

我在网页上有多个UpdatePanels,一个在UserControl内(图像中显示为Purple ColorBox),另一个在主页内。当调用Main页面的分页用户控件(< 1 2 3 >)时,它会显示相应的UpdateProgress'最新消息'部分,但也会显示'{1}}'订阅'用户控件。

我使用UpdatePanelAnimationExtender进行用户控制,将UpdatePanelAnimationExtender用于主页上的Latest-New。

我试图改变属性,但它一直在继续;如果我保留UpdateProgress用于用户控制,则进度条会循环显示并持续显示。

屏幕截图 Update Panel

如何更改此代码以仅显示相应的进度条。我看了过去几天的50个例子,但是尼恩似乎在工作。如果有人能帮助我解决这个问题,我将不胜感激。

UpdateMode="Conditional"

用户控制页码

 <!-- LatestNewArea -->
    <div class="LatestNewArea">
        <asp:UpdatePanel ID="updLatestNews" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Repeater ID="rptLatestNews" runat="server" EnableViewState="False" onitemdatabound="rptLatestNews_ItemDataBound">
                <ItemTemplate>
                <asp:HyperLink ID="hylLatestNews" CssClass="chylLatestNews" runat="server" NavigateUrl=''>
                    <div class="LatestNewsWrapper">
                        <div class="LatestNewsDateBox">
                            <div class="LNYYYY">
                                <asp:Label ID="lblYYYY" runat="server" Text="2012"></asp:Label>  
                            </div>
                            <div class="LNDDMM">
                                <asp:Label ID="lblDDMM" runat="server" Text="12/08"></asp:Label> 
                            </div>
                        </div>
                        <div class="LatestNewsTitle">
                            <asp:Label ID="lblLatestNewsTitle" runat="server" Text="First News for the Website"></asp:Label>
                        </div>
                        <div class="LatestNewsHDate">
                            <asp:Label ID="Label1" runat="server" Text="Hijri: 15 Rajab 1433"></asp:Label>
                        </div>
                        <div class="LatestNewsDesc">
                            <asp:Label ID="Label2" runat="server" Text=""></asp:Label>
                        </div>
                    </div>
                    <div class="LNHLine"> </div>
                </asp:HyperLink>
            </ItemTemplate>
        </asp:Repeater>
        <!-- Pager -->
        <div class="LatestNewsPagerWrapper">
        <div class="LatestNewsPagerInnerWrapper">
            <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="50" AssociatedUpdatePanelID="updLatestNews" >
                <ProgressTemplate>
                <div id="imgLoadingArticleList" class="imgLoadingArticleList">
                    <asp:Image ID="imgLoading" runat="server" ImageUrl="~/images/ajax-loader-bar2.gif"  />
                </div>
                </ProgressTemplate>
            </asp:UpdateProgress>
            <uc1:PagerControl ID="PagerControl1" runat="server"  CssClass="gold-pager"  PageMode="LinkButton"  />
        </div>
        </div>
        <!-- Pager -->
    </ContentTemplate>
    </asp:UpdatePanel>
    </div>
    <!-- LatestNewArea -->

其他信息:ASP.Net 4.0,C#&amp;分页控件是一个使用linkbutton进行分页的用户控件

1 个答案:

答案 0 :(得分:0)

我尝试了很多解决方案,但是没有解决方案。最后,我决定将UpdatePanelAnimationExtender用户控件替换为UpdateProgress,因为我能够捕获AsyPostback的初始UpdatePanel

出于某种原因,当我使用AsyPostback

时,我无法捕获UpdatePanelAnimationExtender

这种方法可以用于多个更新面板,需要捕获后期启动控件

以下是一个工作代码     

    // Function to hide control on update
            function onUpdateOfSubscribe() {
                var panelProg = $get('divImage');
                // set it to visible
                panelProg.style.display = '';
                // hide label if visible      
                var lbl = $get('<%= this.pnlSubscribe.ClientID %>');
                lbl.innerHTML = '';
            }
    //Code to track the initiating event so to associate updateprogress
        var currentPostBackElement;
        function pageLoad() {
            var manager = Sys.WebForms.PageRequestManager.getInstance();
            manager.add_initializeRequest(OnInitializeRequest);
        }
        //On OnInitializeRequest
        function OnInitializeRequest(sender, args) {
            var manager = Sys.WebForms.PageRequestManager.getInstance();
            currentPostBackElement = args.get_postBackElement().parentElement;

            var cmdAuthoriseButton = '<%= btnSubscribe.ClientID %>';
            if (cmdAuthoriseButton == args._postBackElement.id) {
                // Show UpdateProgress for subscribe 
                onUpdateOfSubscribe();
            }
        }
    </script>

<table cellpadding="0" cellspacing="0" class="SubscribeContainer">
        <tr>
            <td align="center">
                <table cellpadding="0" cellspacing="0" class="SubscribeWrapper" border="0" >
                    <tr>
                        <td valign="top">
                        <asp:UpdatePanel ID="updSubscribe" runat="server" UpdateMode="Conditional"   >
                            <ContentTemplate>  
                                    <asp:Panel ID="pnlSubscribe" runat="server" Height="10px">
                                        <div class="SubHeading"><asp:Label ID="lblTitle" runat="server" Text="JOIN US"></asp:Label></div>
                                        <div class="dSubName">
                                            <asp:TextBox ID="txtName" CssClass="txtSubscribe" runat="server" Text="NAME" onfocus="if(this.value=='NAME')this.value='';" onblur="if(this.value=='')this.value='NAME';"></asp:TextBox>
                                        </div>
                                        <div class="dSubEmail">
                                            <asp:TextBox ID="txtEmail" CssClass="txtSubscribe" runat="server" Text="YOUR EMAIL" onfocus="if(this.value=='YOUR EMAIL')this.value='';" onblur="if(this.value=='')this.value='YOUR EMAIL';"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvEmailSub"  runat="server" ErrorMessage="*" 
                                                ControlToValidate="txtEmail" ValidationGroup="SubEmail" ></asp:RequiredFieldValidator>
                                            <asp:RegularExpressionValidator ID="revEmailSub" runat="server" 
                                                ErrorMessage="*" ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                                                ValidationGroup="SubEmail" ></asp:RegularExpressionValidator>
                                        </div>
                                        <div class="dSubSubmit">
                                            <asp:Button ID="btnSubscribe" CssClass="btnSubscribe" runat="server" ValidationGroup="SubEmail" Text="Subscribe" onclick="btnSubscribe_Click" />
                                        </div> 
                                    </asp:Panel> 
                                        <div class="dSubMSG"> 
                                        <asp:Label ID="lblMSG" runat="server" Text=""></asp:Label>
                                    </div>
                                                <div id="divImage" style="display:none" class="dSubAni">
                                                    <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/loader-sub.png" Visible="true"/>
                                                </div>

                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="btnSubscribe" EventName="Click" />
                            </Triggers>
                        </asp:UpdatePanel>
                    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updSubscribe" >
                        <ProgressTemplate>

                        </ProgressTemplate>
                    </asp:UpdateProgress>


                           </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>