我有一个带有 ToolkitScriptManager 和三个更新面板的页面,每个更新面板都有基于控件的触发器,现在我的问题是触发任何服务器端事件显示进度条,如百分比示例,如何在 PostBackTriggers 和 AsyncPostBackTriggers 控件中像这样显示,我的代码是
<asp:UpdatePanel ID="up1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TxtZip" EventName="textchanged" />
</Triggers>
<ContentTemplate>
<asp:TextBox ID="TxtZip" runat="server" AutoPostBack="true" ClientIDMode="Static"
MaxLength="6" onkeypress="return isNumberKey(event)" CssClass="txtstyle" OnTextChanged="TxtZip_TextChanged"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:PostBackTrigger ControlID="IBtnSave" />
</Triggers>
<ContentTemplate>
<span class="art-button-wrapper"><span class="l"></span><span class="r"></span>
<asp:Button ID="IBtnSave" runat="server" Text="Submit/Save" CssClass="art-button"
ClientIDMode="Static" OnClientClick="return postbackButtonClick()" OnClick="IBtnSave_Click" />
</span>
</ContentTemplate>
</asp:UpdatePanel>
我的进度条形码
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="true">
<ProgressTemplate>
<div id="Progressbar" class="Progressbar" align="center" valign="middle" runat="server">
<asp:Image ID="Image1" Width="75" Height="95" runat="server" ImageUrl="~/images/animation_processing.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
而 Java 脚本代码是
<script type="text/javascript">
//update panel and postback trigger with fileupload control upadteprogressbar code
var updateProgress = null;
function postbackButtonClick() {
updateProgress = $find("<%= UpdateProgress1.ClientID %>");
window.setTimeout("updateProgress.set_visible(true)", updateProgress.get_displayAfter());
return true;
}
</script>
这段代码只工作回发触发器的原因是当按钮点击之前触发onclick事件时,该事件调用java脚本函数,但异步回发触发器不调用该函数,如何处理该代码并显示带有百分比进程的进度条,给我任何建议
只需在aspx内容页面中添加以下代码即可正常工作
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
Sys.Application.add_init(appl_init);
function hideProgressBar() {
// var updateProgress = $find("<%= UpdateProgress1.ClientID %>");
// updateProgress.style.visibility = "hidden";
$("#MainContent_UpdateProgress1").hide()
}
function appl_init() {
var pgRegMgr = Sys.WebForms.PageRequestManager.getInstance();
pgRegMgr.add_beginRequest(postbackButtonClick);
pgRegMgr.add_endRequest(hideProgressBar)
}
</script>