Asp.net"页面加载中"效果实现(转)
在网上找了好多,实现方式大多是使用定时器
个人觉得定时器会造成一定程度上的假象
(如:定时器还没结束页面已经加载完毕,或定时器结束后页面还没加载完成)
本方法利用的是javascript,先网页面里面写入一个层,显示加载框,然后等页面结束后
在body的onload中写入事件,隐藏该对话框
方法(我的系统是多个页面,所以写了一个公用的类common.cs):
在类里面加入如下函数(也可在每个代码后文件中写入):
#region "页面加载中效果"
/// <summary>
/// 页面加载中效果
/// </summary>
public static void initJavascript()
{
HttpContext.Current.Response.Write(" <mce:script language=JavaScript type=text/javascript><!--
");
HttpContext.Current.Response.Write("var t_id = setInterval(animate,20);");
HttpContext.Current.Response.Write("var pos=0;var dir=2;var len=0;");
HttpContext.Current.Response.Write("function animate(){");
HttpContext.Current.Response.Write("var elem = document.getElementById('progress');");
HttpContext.Current.Response.Write("if(elem != null) {");
HttpContext.Current.Response.Write("if (pos==0) len += dir;");
HttpContext.Current.Response.Write("if (len>32 || pos>79) pos += dir;");
HttpContext.Current.Response.Write("if (pos>79) len -= dir;");
HttpContext.Current.Response.Write(" if (pos>79 && len==0) pos=0;");
HttpContext.Current.Response.Write("elem.style.left = pos;");
HttpContext.Current.Response.Write("elem.style.width = len;");
HttpContext.Current.Response.Write("}}");
HttpContext.Current.Response.Write("function remove_loading() {");
HttpContext.Current.Response.Write(" this.clearInterval(t_id);");
HttpContext.Current.Response.Write("var targelem = document.getElementById('loader_container');");
HttpContext.Current.Response.Write("targelem.style.display='none';");
HttpContext.Current.Response.Write("targelem.style.visibility='hidden';");
HttpContext.Current.Response.Write("}");
HttpContext.Current.Response.Write("
// --></mce:script>");
HttpContext.Current.Response.Write("<mce:style><!--
"
相关文档:
ObjectDataSource 控件基于 SelectMethod、InsertMethod、UpdateMethod 或 DeleteMethod 属性中所标识的方法名称以及组成业务对象方法签名的参数名来调用业务对象方法。在业务对象中创建方法时,必须确保业务对象方法所接受的参数名和类型与 ObjectDataSource 控件传递的参数名和类型匹配。(参数顺序并不重要。)
  ......
Page_Load--页面加载事件.
Page.IspostBack判断是否第一次加载。
每次响应服务信息(既客户请求ASP.NET页面-ASPX文件或Web服务-
ASMX文件)就加载一次(执行一次Page_Load)。
加载的时候并不是每次多编译一次代码文件,因为:每一次请求
ASPX文件时并不是多要进行一次编译,而是第一次执 ......
以前做.NET winform的时候,一直都是用 Console.Write向控制台输出信息的,这次做web的时候,发现这个语句用不了。
查了一下资料,才发现web程序执行时,是被附加到IIS进程的一个单独的AppDomain中的,所以就算有输出也看到,所以Console.Write调试信息无法显示出来。
那么解决办法是,用debug代替:
System.Diagn ......