简体   繁体   中英

.net progress bar in a asp.net we application

Is it possible to have a .net progress bar in a asp.net web application.

I tried doing this:

    ProgressBar pb = new ProgressBar();
    pb.Name = "pb";
    pb.Value = 30;

    pb.MarqueeAnimationSpeed = 30;

    pb.Location = new System.Drawing.Point(20, 20);

    pb.Width = 200;
    pb.Height = 30;
    Controls.Add(pb);

but this :

Controls.Add(pb);

Doesnt work,

Any idea how to do this? or something the same?

Thanks

no this is not possible - ASP.NET pages are just rendered HTML that gets send to the client (web-browser). The progress-bar is a client-side control.

If you need something like this on the client you may to use Javascript/JQuery/AJAX or something similar.

Here is a version for JQuery And here is a nice article on this with AJAX

您无法在网络上使用此控件。

To make it work you need to write an algorithm(maybe using an async call) to update the progress bar.it won't work if you use the classic request/response because you would not have the chance to update your progress bar. you need a way to read a kind of value at regular interval to update the progress bar and give the perception to the users that something is happening. If you want to go for a "fake" one you could use the one showed at the link below:

http://jqueryui.com/demos/progressbar/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM