0

我有一个带有三个 ajax 更新面板的 asp.net 页面。在每个面板中都有一些控件,每个 updatepanel 作为 ajax 更新进度控件。第一个更新面板有一个下拉菜单,其中 autopostback = true。第二个和第三个更新面板将此下拉列表作为 asynpostback 触发器。当我在下拉列表中更改选择时,只会出现第一个 updateprogress 加载图像,而其他则不会出现。

我该如何解决?

4

1 回答 1

0

尝试更改UpdateMode="Conditional"更新面板中的。

例子

<script type="text/javascript">

        // 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.pnlRegister.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 = '<%= btnRegister.ClientID %>';
            if (cmdAuthoriseButton == args._postBackElement.id) {
                // Show UpdateProgress for subscribe 
                onUpdateOfSubscribe();
            }
        }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="FormWrapper">
        <div class="rowHeader">

        </div>
            <asp:UpdatePanel ID="updRegister" runat="server" UpdateMode="Conditional"   >
            <ContentTemplate>  
                    <asp:Panel ID="pnlRegister" runat="server" Height="10px">
                        <div class="row" style="display:none;">
                            <asp:Label ID="Label7" runat="server" Text="Activity:" class="lbl"></asp:Label>
                            <asp:DropDownList ID="ddActivities" runat="server" CssClass="dd252"  DataTextField="EventTitle" DataValueField="EventID">
                            </asp:DropDownList>
                        </div>
                        <div class="row">
                            <asp:Label ID="lblSName" runat="server" Text="Name:" class="lbl"></asp:Label>
                            <asp:TextBox ID="txtSName" runat="server" CssClass="txt"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2"  runat="server" ErrorMessage="*" ControlToValidate="txtSName" ValidationGroup="ActivityReg" ></asp:RequiredFieldValidator>
                        </div>
                        <div class="row">
                            <asp:Label ID="lblSAge" runat="server" Text="Age:" class="lbl"></asp:Label>
                            <asp:TextBox ID="txtSAge" runat="server" CssClass="txt"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4"  runat="server" ErrorMessage="*" ControlToValidate="txtSAge" ValidationGroup="ActivityReg" ></asp:RequiredFieldValidator>
                            <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="*" ControlToValidate="txtSAge" MaximumValue="100" MinimumValue="4" 
                                ValidationGroup="ActivityReg" Type="Integer" ></asp:RangeValidator>
                        </div>

                        <div class="row">
                            <asp:Label ID="lblGMobile" runat="server" Text="Guardian Mobile:" class="lbl"></asp:Label>
                            <asp:TextBox ID="txtGMobile" runat="server" CssClass="txt"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5"  runat="server" ErrorMessage="*" ControlToValidate="txtGMobile" ValidationGroup="ActivityReg" ></asp:RequiredFieldValidator>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1"  runat="server" ErrorMessage="*" ControlToValidate="txtGMobile" ValidationGroup="ActivityReg" ></asp:RequiredFieldValidator><asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"  ValidationGroup="ActivityReg"
                                ControlToValidate="txtGMobile" ErrorMessage="*" ValidationExpression="[0-9 ]{9,}"></asp:RegularExpressionValidator>
                        </div>
                        <div class="rowDouble">
                            <asp:Label ID="lblAddress" runat="server" Text="Address:" class="lbl"></asp:Label>
                            <asp:TextBox ID="txtAddress" runat="server" CssClass="txtDouble" TextMode="MultiLine"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3"  runat="server" ErrorMessage="*" ControlToValidate="txtAddress" ValidationGroup="ActivityReg" ></asp:RequiredFieldValidator>   
                        </div>
                        <div class="row">
                            <asp:Button ID="btnRegister" CssClass="btn" runat="server" 
                                ValidationGroup="ActivityReg" Text="Register" onclick="btnRegister_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/ajax-loader-gray.png" Visible="true"/>
                    </div>

                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnRegister" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
            <asp:UpdateProgress ID="updProgressRegister" runat="server" AssociatedUpdatePanelID="updRegister" >
                <ProgressTemplate>

                </ProgressTemplate>
            </asp:UpdateProgress>
    </div>
    </form>

我有其他带有 UpdatePanel 和进度条的用户控件我捕获了 ascy 回发的源并相应地隐藏或显示进度条。希望这会有所帮助..但你可能需要努力

于 2012-06-28T13:20:56.683 回答