JavaScript implements a simple progress bar _javascript tips

Source: Internet
Author: User
Tags flush

Example One:

<!doctype html>  

To share a combination of. Net

Create a Web project, add a new Item->html page, named Progressbar.htm, which reads:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Background code, Default.aspx.cs:

Using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using System.Threading;

Using System.IO;
    Public partial class _default:system.web.ui.page {private void beginprogress () {//Show progress bar interface based on progressbar.htm
    String templatefilename = Path.Combine (Server.MapPath ("."), "progressbar.htm");
    StreamReader reader = new StreamReader (@templateFileName, System.Text.Encoding.GetEncoding ("GB2312")); string html = reader.
    ReadToEnd (); Reader.
    Close ();
    Response.Write (HTML);
  Response.Flush (); private void setprogress (int percent) {string jsblock = ' <script>setporgressbar (' + percent. ToString () + "');
    </script> ";
    Response.Write (Jsblock);
  Response.Flush (); private void Finishprogress () {string jsblock = ' <script>setcompleted (); &LT;/SCRIPT&Gt; ";
    Response.Write (Jsblock);
  Response.Flush ();

    } private void Page_Load (object sender, System.EventArgs e) {beginprogress ();

      for (int i = 1; I <= i++) {setprogress (i);
    This place uses thread hibernation instead of the actual operation, such as loading data such as System.Threading.Thread.Sleep (50); 
  } finishprogress ();
 } 
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.