德仔

工作学习之笔记

Ext.Net 1.x_Ext.Net.TaskManager模拟进度条

一直很想做一个登陆时候的进度条 上图先:

 

   <ext:Button ID="btnlogin" runat="Server" Text="登陆"  Icon="Accept" OnDirectClick="Login_Click" >
            </ext:Button>
             
    <ext:TaskManager ID="TaskManager1" runat="server">
        <Tasks>
            <ext:Task 
                TaskID="Task1"
                Interval="1000" 
                AutoRun="false">
                <DirectEvents>
                    <Update OnEvent="RefreshProgress" />
                </DirectEvents>                    
            </ext:Task>
        </Tasks>
    </ext:TaskManager>

 protected void Login_Click(object sender, DirectEventArgs e)
    {
        Model._Login _lg = new Model._Login();
        _lg.UserCode = this.txtusername.Text.Trim();
        _lg.Password = this.txtpassword.Text.Trim();
        BLL.Login lg = new BLL.Login();
        if (lg.UserLogin(_lg))
        {


            X.Msg.Show(new MessageBoxConfig
            {
                Title = "请等待",
                Message = "正在加载项",
                ProgressText = "初始化中...",
                Width = 300,
                Progress = true,
                Closable = false,
                AnimEl = this.btnlogin.ClientID
            });

            this.StartLongAction();
        }
        else 
        {
            X.Msg.Alert("警告", "账号或密码有误").Show();

        }

    }
    private void StartLongAction()
    {
        this.Session["Task1"] = 0;
        ThreadPool.QueueUserWorkItem(LongAction);

        this.TaskManager1.StartTask("Task1");
    }


    private void LongAction(object state)
    {
        for (int i = 0; i < 100; i++)
        {
            Thread.Sleep(100);
            this.Session["Task1"] = i + 1;
        }
        this.Session.Remove("Task1");
    }


    protected void RefreshProgress(object sender, DirectEventArgs e)
    {
        object progress = this.Session["Task1"];
        if (progress != null)
        {
            X.Msg.UpdateProgress(((int)progress) / 100f, string.Format(" {0} % {1}", progress.ToString(), 100));
        }
        else
        {
            this.TaskManager1.StopTask("Task1");
            X.MessageBox.Hide();
            //this.ResourceManager1.AddScript("Ext.Msg.notify('Done', 'Your items were loaded!');");
            Response.Redirect("Default.aspx");
        }
    }

阅读更多

扫码向博主提问

去开通我的Chat快问

david_520042

博客专家

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • ERP
  • .NET
  • SQL
  • Ext.Net
  • DevExpress
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/david_520042/article/details/6122970
个人分类: 前端设计 Ext.Net
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

Ext.Net 1.x_Ext.Net.TaskManager模拟进度条

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭