protected void Button_Wait(object sender, AjaxEventArgs e)
{
Ext.Msg.Show(new MessageBox.Config
{
Title = "请等待",
Message = "系统正在加载,请等待",
ProgressText = "系统加载中",
Width = 300,
Progress = true,
Closable = false,
AnimEl = this.btnWait.ClientID
});
this.StartLongAction();
}
private void StartLongAction()
{
this.Session["Task1"] = 0;
ThreadPool.QueueUserWorkItem(LongAction);
this.TaskManager1.StartTask("Task1");
}
private void LongAction(object state)
{
for (int i = 0; i < 10; i++)
{
Thread.Sleep(1000);
this.Session["Task1"] = i + 1;
}
this.Session.Remove("Task1");
}
protected void RefreshProgress(object sender, AjaxEventArgs e)
{
object progress = this.Session["Task1"];
if (progress != null)
{
Ext.MessageBox.UpdateProgress(((int)progress) / 10f, "");
}
else
{
this.TaskManager1.StopTask("Task1");
Ext.MessageBox.Hide();
this.ScriptManager1.AddScript("ProgressResult();");
}
}
<ext:Button ID="btnWait" runat="server" Text="Wait">
<AjaxEvents>
<Click OnEvent="Button_Wait"></Click>
</AjaxEvents>
</ext:Button>
<ext:TaskManager ID="TaskManager1" runat="server">
<Tasks>
<ext:Task
TaskID="Task1"
Interval="1000"
AutoRun="false">
<AjaxEvents>
<Update OnEvent="RefreshProgress" />
</AjaxEvents>
</ext:Task>
</Tasks>
</ext:TaskManager>
<script type="text/javascript">
function ProgressResult() {
alert("进度条走完了");
}
</script>
报错信息:TaskManager1.startTask("taskProbar")对象不支持此属性或方法