原创

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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://david.blog.csdn.net/article/details/6122970

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

 

   <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");
        }
    }

文章最后发布于: 2011-01-07 16:29:00
展开阅读全文
0 个人打赏
私信求帮助

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

©️2019 CSDN 皮肤主题: 鲸 设计师: meimeiellie

分享到微信朋友圈

×

扫一扫,手机浏览