The method is simple. Put the code up here and see.
It was packed into a control. Download Address:
http://upserver4.ys168.com/ys168up/D1/YY1.aspx?f= 050p1d8e0e3e5d9d5g6ali7a00a05aka03d6a00a08a08i5f9g0e0d9e0d8d6e1a24e6e1d9e5d9c3
The following is the source code:
===================================
Using System;
Namespace Hdcontrol
{
<summary>
Summary description for Loading.
</summary>
public class Loading
{
Private System.Web.UI.Page Sender;
private string strImagePath;
public Object Page
{
Get
{
return Sender;
}
Set
{
Sender = (System.Web.UI.Page) value;
}
}
public string imagemapth
{
Get
{
return strImagePath;
}
Set
{
strImagePath = value;
}
}
Public Loading ()
{
//
}
Public Loading (object sender)
{
Page = sender;
}
Public Loading (Object sender,string imagemapth)
{
Page = sender;
This.strimagepath = imagemapth;
}
<summary>
Load script to Page
</summary>
public void Load ()
{
if (!this. Sender.isclientscriptblockregistered ("Startscript"))
{
This. Sender.registerclientscriptblock ("Startscript", this. Start ());
This. Sender.registerstartupscript ("Endscript", this. End ());
}
}
<summary>
Script start.
</summary>
<returns></returns>
private String Start ()
{
String strstyle = "Border-top-style:none;" Border-right-style:none; Border-left-style:none; Border-bottom-style:none ";
System.Text.StringBuilder strscript = new System.Text.StringBuilder ();
Strscript.append ("<div id=/" loading/">");
Strscript.append ("<table width=/" 100%/"height=/" 100%/"border=/" 0/"cellpadding=/" 0/"cellspacing=/" 0/"style=/" "+ Strstyle +"/">");
Strscript.append ("<tr style=/" "+ Strstyle +"/"><td width=/" 100%/"height=/" 100%/"align=/" center/"valign=/" middle/"style=/" "+ Strstyle +"/">");
Strscript.append ("Strscript.append ("</td></tr>");
Strscript.append ("</table></div>");
return strscript.tostring ();
}
<summary>
Script end.
</summary>
<returns></returns>
private String End ()
{
System.Text.StringBuilder strscript = new System.Text.StringBuilder ();
Strscript.append ("<script language=/" javascript/">");
Strscript.append ("Window.document.getElementById" (/"loading/"). Style.display =/"none/"; ");
Strscript.append ("</script>");
return strscript.tostring ();
}
}
}
=========================
First in the face page
Using Hdcontrol;
Call method (in Page_Load):
loadingcontrol.loading objload = new Loadingcontrol.loading (This, "images/loading.gif");
Objload.load ();
Or:
loadingcontrol.loading objload = new loadingcontrol.loading ();
Objload.page = this;
objload.imagemapth = "Images/loading.gif";
Objload.load ();