如何在网站上初始化进度条? [英] how to initialize a progress bar in website ?

查看:115
本文介绍了如何在网站上初始化进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在做一些功能,用户可以在其中等待文件从数据库中下载.同时,在挖掘数据时,我希望他查看进度条.我看过很多示例,但是它们都在Windows应用程序上,而不是在使用c#的网站上.此外,我已经进行了一些编码,但是此INITIALIZE COMPONENT()与进度条一起使用了吗?
如何完成任务并开始运行?
这是我已经完成的一些编码...请看一下,让我知道我一直在哪里出错?

Hi all,
I am making some functionality in which user waits for the file to get download from the data base. Meantime when the data is mined I want him to see the progress in progress bar. I have seen many examples but they are all on windows application not on websites using c#. Moreover I have done some coding but wht is this INITIALIZE COMPONENT() used with progress bar ?
How can i achieve my task up and running ?
Here is some coding I have done... Kindly look at it and lemme know where I am geting wrong all the way ?

ProgressBar pbar = new ProgressBar();
    BackgroundWorker bw = new BackgroundWorker();
 pbar.Minimum = 0;
        pbar.Maximum = 100;
        bw.DoWork += new DoWorkEventHandler(worker_DoWork);
        bw.ProgressChanged += new   ProgressChangedEventHandler(worker_ProgressChanged);
        
        pbar.Value = pbar.Minimum;
        bw.RunWorkerAsync();

  void worker_DoWork(object sender, DoWorkEventArgs e)
    {
        for (int i = 1000; i >= 0; i--)
        {
            Thread.Sleep(50);
            int percent = (1000 - i) / 10;
            bw.ReportProgress(percent);
        }
    }

    void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        System.Web.UI.WebControls.Label label1 = new System.Web.UI.WebControls.Label();
        pbar.Value = e.ProgressPercentage;
        label1.Text = e.ProgressPercentage + "%";
    }

推荐答案

找到的代码无法正常工作.

Windows应用程序和网站之间有很大的区别.最重要的是,网站是基于客户端服务器的,并使用html进行通信.客户端向服务器发送请求,服务器发送响应.直到客户端发送了另一个请求,然后再进行其他通信.

仅使用html不能实现此目的,您将需要 ajax [ http://csharptechies.blogspot. nl/2010/09/displaying-jquery-progressbar-with-ajax.html [
The code you have found is not going to work.

There is a big difference between windows applications and websites. Most important is that a website is client-server based and uses html for communication. The client sends a request to the server and the server sends a response. There is no other communication until another request is sent from the client.

With html only you cannot achieve this, you will need ajax[^] to send asynchronous requests from the client to get the status of the download and update the screen. There are also flash progress bars, but I wouldn''t recommend those.

Take a look at this article to get started: http://csharptechies.blogspot.nl/2010/09/displaying-jquery-progressbar-with-ajax.html[^]


这篇关于如何在网站上初始化进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆