ASP.net]Loading绘制

来源:百度文库 编辑:神马文学网 时间:2024/04/28 07:27:26
方法很简单。把代码放上来大家看看!
打了包成了个控件。下载地址:
http://upserver4.ys168.com/ys168up/D1/YY1.ASPx?f=050P1D8E0E3E5D9D5G6ALI7A00A05AKA03D6A00A08A08I5F9G0E0D9E0D8D6E1A24E6E1D9E5D9C3
下面是源码:
===================================
using System;
namespace HDControl
{
///
/// Summary description for Loading.
///

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;
}
///
/// Load script to page
///

public void Load()
{
if ( !this.Sender.IsClientScriptBlockRegistered( "startScript" ) )
{
this.Sender.RegisterClientScriptBlock( "startScript",this.Start() );
this.Sender.RegisterStartupScript( "endScript",this.End() );
}
}
///
/// Script start.
///

///
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( "
" );
strScript.Append( "" );
strScript.Append( "" );
strScript.Append( "
" );
strScript.Append( "" );
strScript.Append( "
" );
return strScript.ToString();
}
///
/// Script end.
///

///
private string End()
{
System.Text.StringBuilder strScript = new System.Text.StringBuilder();
strScript.Append( "" );
return strScript.ToString();
}
}
}
=========================
先在面页中
using HDControl;
调用方法(在Page_Load里):
LoadingControl.Loading objLoad = new LoadingControl.Loading( this,"Images/loading.gif" );
objLoad.Load();
或:
LoadingControl.Loading objLoad = new LoadingControl.Loading( );
objLoad.Page = this;
objLoad.ImageMapth = "Images/loading.gif";
objLoad.Load();