我的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>
以上是想要更新的更新面板。 另一个更新面板是mastepage,在这里是;
<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>
感谢您的回复。
答案 0 :(得分:0)
实际上我能看到的是,在更新面板中,UpdateMode设置为“Conditional”。 这将只刷新该面板。