zoukankan      html  css  js  c++  java
  • 使用 Asp.Net Response.Write() 制作实时进度条

    准备:

      一个 StudyResponse.aspx 页面和 CodeBehind 文件。

    Web 页面中的内容如下:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StudyResponse.aspx.cs" Inherits="WebApplication1.StudyResponse" %>

    Web 页面的 CodeBehind 中的代码如下:

    namespace WebApplication1
    {
        public partial class StudyResponse : System.Web.UI.Page
        {
            private readonly StringBuilder _builder = new StringBuilder();
    
            protected void Page_Load( object sender, EventArgs e )
            {
                for (var i = 1; i <= 50; i++)
                {
                    Thread.Sleep(50);
                    _builder.Clear();
    
                    if (i == 1)
                    {
                        _builder.Append("<html><head></head>  <body>");
                        _builder.Append("<script src='FileUpload.js' type='text/javascript'></script>");
    
                        _builder.AppendLine("<div style=' 202px; height: 22px; border: 1px solid #0094ff;'>");
                        _builder.AppendLine("<div id='progress' style=' 0; height: 20px; background-color: #ccc; margin: 1px;'></div>");
                        _builder.AppendLine("</div>");
    
                        _builder.AppendLine("<script type='text/javascript'>");
                        _builder.AppendLine("_setProgress(" + i * 4 + ");");
                        _builder.AppendLine("</script>");
                        _builder.Append("</body></html>");
                    }
                    else
                    {
                        _builder.AppendLine( "<script type='text/javascript'>" );
                        _builder.AppendLine( "_setProgress(" + i * 4 + ");" );
                        _builder.AppendLine( "</script>" );
                    }
    
                    this.Response.Write(_builder.ToString());
                    this.Response.Flush();
                }
            }
        }
    }

    效果预览:

    参考:http://www.cnblogs.com/isun/p/4178942.html

  • 相关阅读:
    POJ 3164 Command Network 最小树形图 朱刘算法
    区间dp专题
    HDU2896病毒入侵AC_自动机
    HDU2222Keywords Search AC_自动机
    Linux cat命令参数及使用方法详解
    MySQL分支Percona, cmake编译安装
    PHP网站简单架构 – 单独跑php-fpm
    Tengine – Nginx衍生版
    jemalloc优化MySQL、Nginx内存管理
    TCMalloc优化MySQL、Nginx、Redis内存管理
  • 原文地址:https://www.cnblogs.com/jroger/p/4180500.html
Copyright © 2011-2022 走看看