Implemented with JavaScript (the effect that the page is loading)

Source: Internet
Author: User
Tags object net visibility window visual studio
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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.