zoukankan
html css js c++ java
对于长时间装载的ASP.NET页面,如何在客户端浏览器中显示进度?
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Web;
using
System.Web.SessionState;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.HtmlControls;
using
System.Threading;
namespace
Exercise
...
{
/**/
///
<summary>
///
WebForm2 的摘要说明。
///
</summary>
public
class
WebForm2 : System.Web.UI.Page
...
{
private
void
Page_Load(
object
sender, System.EventArgs e)
...
{
//
对于长时间装载的ASP.NET页面如何在客户端浏览器中显示进度?
//
对于加载时间比较长的ASP.NET页面,
//
我们可以在客户端浏览器中显示进度条来显示页面正在装载。下面就是具体的实现过程:
if
(
!
IsPostBack)
...
{
Response.Write(
"
<div id='mydiv' >
"
);
Response.Write(
"
_
"
);
Response.Write(
"
</div>
"
);
Response.Write(
"
<script>mydiv.innerText = '';</script>
"
);
Response.Write(
"
<script language=javascript>;
"
);
Response.Write(
"
var dots = 0;var dotmax = 10;function ShowWait()
"
);
Response.Write(
"
{var output; output = '正在装载页面';dots++;if(dots>=dotmax)dots=1;
"
);
Response.Write(
"
for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText = output;}
"
);
Response.Write(
"
function StartShowWait(){mydiv.style.visibility = 'visible';
"
);
Response.Write(
"
window.setInterval('ShowWait()',1000);}
"
);
Response.Write(
"
function HideWait(){mydiv.style.visibility = 'hidden';
"
);
Response.Write(
"
window.clearInterval();}
"
);
Response.Write(
"
StartShowWait();</script>
"
);
Response.Flush();
for
(
long
i
=
0
;i
<
99999999999
;i
++
) i
=
i
++
;
//
or Thread.Sleep(10000);
}
}
Web 窗体设计器生成的代码
#region
Web 窗体设计器生成的代码
override
protected
void
OnInit(EventArgs e)
...
{
//
//
CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base
.OnInit(e);
}
/**/
///
<summary>
///
设计器支持所需的方法 - 不要使用代码编辑器修改
///
此方法的内容。
///
</summary>
private
void
InitializeComponent()
...
{
this
.Load
+=
new
System.EventHandler(
this
.Page_Load);
}
#endregion
}
}
<%
...
@ Page language
=
"
c#
"
Codebehind
=
"
WebForm2.aspx.cs
"
AutoEventWireup
=
"
false
"
Inherits
=
"
Exercise.WebForm2
"
%>
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
<
HTML
>
<
HEAD
>
<
title
>
WebForm2
</
title
>
<
meta
name
="GENERATOR"
Content
="Microsoft Visual Studio .NET 7.1"
>
<
meta
name
="CODE_LANGUAGE"
Content
="C#"
>
<
meta
name
="vs_defaultClientScript"
content
="JavaScript"
>
<
meta
name
="vs_targetSchema"
content
="http://schemas.microsoft.com/intellisense/ie5"
>
<
script
language
="javascript"
>
...
HideWait();
</
script
>
</
HEAD
>
<
body
MS_POSITIONING
="GridLayout"
>
<
form
id
="Form1"
method
="post"
runat
="server"
>
</
form
>
</
body
>
</
HTML
>
查看全文
相关阅读:
selenium+python处理Alert弹窗
HTML在网页上不能显示图片问题
制作python程序windows安装包(飞机大战源码)
python读取ini文件
python杀死Windows后台程序
python3中文乱码解决方法
算法04
Windows10
Windows10 快捷键
文件夹选项-安装功能-window服务
原文地址:https://www.cnblogs.com/happyday56/p/1363413.html
最新文章
什么叫变量?什么叫成员变量?什么叫字段?什么叫属性?
类和对象是什么关系?
Go 内存模型
Go 语言之json
Go 正则表达式
Go fmt包
Go 将字符串写入文件
Go 读取文件
Go 反射
Go 头等函数
热门文章
Go 异常处理
Go 自定义错误处理
mysql常用命令
Postman使用简介
python在selenium中做自动化测试用法详解
重庆邮电大学教务在线查询课表系统(性能测试)
python实现rtsp取流并截图
html网页乱码
python冒泡排序
selenium下拉选择框处理
Copyright © 2011-2022 走看看