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><!--
"
相关文档:
在Global.asax启动一条线程就ok了,下面是启动线程定时写文件的例子
Global.asax
C# code
Code
1<%@ Application Language="C#" %>
2<%@ Import Namespace="System.IO" %>
3<%@ Import Namespace="System.Threading" %>
4<script runat="server">
5 ......
ASP.NET 页运行时,此页将经历一个生命周期,在生命周期中将执行一系列处理步骤。这些步骤包括初始化、实例化控件、还原和维护状态、运行事件处理程序代码以及进行呈现。了解页的生命周期非常重要,这样就能在合适的生命周期阶段编写代码,以达到预期效果。此外,如果开发自定义控件,则必须熟悉页生命周期,从而正确地初始 ......
////今天在修改程序的时候发现一个小的问题特记录如下:
//////有时候datetime无法转成string,可以用getdate()直接插入就可以了
string str = "update adaddress set shenhe=" + ck + " ,shentime=getDate() where id=" + uid + "";
/////////////////////////////////////////
以下具体介绍日期怎样转换
DateTime.Now ......
ObjectDataSource 控件基于 SelectMethod、InsertMethod、UpdateMethod 或 DeleteMethod 属性中所标识的方法名称以及组成业务对象方法签名的参数名来调用业务对象方法。在业务对象中创建方法时,必须确保业务对象方法所接受的参数名和类型与 ObjectDataSource 控件传递的参数名和类型匹配。(参数顺序并不重要。)
  ......