0

我的 aspx 页面中有两个更新面板。我想使用 javascript 代码显示进度。但是,当我单击一个特定更新面板的触发按钮时,两个更新面板都在更新。单击按钮时,我只想更新一个。

<script type="text/javascript">
                var prm = Sys.WebForms.PageRequestManager.getInstance();
                prm.add_initializeRequest(prm_InitializeRequest);
                prm.add_endRequest(prm_EndRequest);
                function prm_InitializeRequest(sender, args) {
                    $('#loading').show("slow");
                    /*var panelProg = $get('loading');
                    panelProg.style.display = '';*/
                    $get(args._postBackElement.id).disabled = true;
                }
                function prm_EndRequest(sender, args) {
                    $('#loading').hide("slow");

                    /*var panelProg = $get('loading');

                    panelProg.style.display = 'none';*/
                    $get(sender._postBackSettings.sourceElement.id).disabled = false;
                }

以上是我的javascript代码。

<asp:UpdatePanel ID="updateQuestions" runat="server">
                <ContentTemplate>
                    <div class="descHeader" style="width: 600px;">
                        <asp:Label ID="Label2" runat="server" Text="Last 10 Questions"></asp:Label>
                    </div>
                    <div class="descContent" style="width: 600px; height: auto;">
                        <div id="loading" style="display: none; height: 60px;">
                            <asp:Image ID="img1" runat="server" ImageUrl="~/images/site/process.gif" />
                        </div>
                        <asp:Panel ID="pnlQuestions" runat="server">
                        </asp:Panel>
                    </div>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnAsk" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>

上面是要更新的更新面板。另一个更新面板在母版页中,在这里;

<asp:UpdatePanel ID="uPCheckin" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <asp:Panel ID="pnlCheckIn" runat="server" CssClass="pnlCheckIn">
                    <asp:Label ID="Label1" runat="server" Text="Where are you now ?" Font-Size="10px"
                        ForeColor="Black"></asp:Label>
                    <br />
                    <asp:TextBox ID="txtCheckIn" runat="server" ForeColor="Gray">
                    </asp:TextBox>
                    <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" WatermarkText="Type City Name"
                        Enabled="True" TargetControlID="txtCheckIn">
                    </asp:TextBoxWatermarkExtender>
                    <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" CompletionSetCount="4"
                        CompletionInterval="4" EnableCaching="true" Enabled="True" MinimumPrefixLength="3"
                        ServiceMethod="NewDestinationComplete" ServicePath="~/DestinationComplete.asmx"
                        TargetControlID="txtCheckIn" CompletionListCssClass="autocomplete_completionListElement"
                        CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem">
                    </asp:AutoCompleteExtender>
                    <asp:Button ID="btnCheckIn" runat="server" Text="Check-In" CssClass="btnSaveChanges"
                        OnClick="btnCheckIn_Click" />
                    <br />
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>

感谢您的任何回复。

4

1 回答 1

0

实际上,我可以看到,在您的更新面板中,UpdateMode 设置为“有条件的”。这将只刷新该面板。

于 2012-08-07T13:23:28.910 回答