Load | page
Code files:
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 Ajaxtest
{
/**////<summary>
Summary description of the WebForm2.
</summary>
public class WebForm2:System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1;
private void Page_Load (object sender, System.EventArgs e)
{
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 = ' loading page ';d ots++;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 ()//This sentence is the most critical
}
private void Button1_Click (object sender, System.EventArgs e)
{
When clicking a button, assume that the request takes a long time (set to 10 seconds here)
System.Threading.Thread.Sleep (10000);
This. Label1.Text = "finally loaded finished";
}
Web Forms Designer generated Code #region Web Forms Designer generated code
Override protected void OnInit (EventArgs e)
{
//
CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
Base. OnInit (e);
}
/**////<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
This. Button1.Click + = new System.EventHandler (this. Button1_Click);
This. Load + = new System.EventHandler (this. Page_Load);
}
#endregion
}
}
Paging File:
<%@ Page language= "C #" codebehind= "WebForm2.aspx.cs" autoeventwireup= "false" inherits= "Ajaxtest.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>
HideWait ();
</script>
</HEAD>
<body ms_positioning= "GridLayout" >
<form id= "Form1" method= "POST" runat= "Server" >
<font face= "Song Body" >
<asp:button id= "Button1" style= "Z-INDEX:101; left:480px; Position:absolute; top:200px "runat=" Server "
text= "button" ></asp:Button>
<asp:label id= "Label1" style= "z-index:102; left:632px; Position:absolute; top:240px "runat=" Server >Label</asp:Label></FONT>
</form>
</body>
</HTML>
Http://fanrsh.cnblogs.com/archive/2006/06/14/425888.html