本例中的实现方法要求打开的页面 body 是个空 body,因为里面的东西都会在 Response.Write 之后清空。
页面里的所有元素均由Ext创建。
public partial class database : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
init();
}
}
public static void init()
{
HttpContext.Current.Response.Write("<script language='JavaScript' type='text/javascript'>");
HttpContext.Current.Response.Write("var dbid='" + HttpContext.Current.Request.QueryString["id"] + "';"); //将数据库ID存放到页面
HttpContext.Current.Response.Write("function remove_loading() {");
HttpContext.Current.Response.Write("document.getElementById('loader_container').style.display='none';");
HttpContext.Current.Response.Write("document.getElementById('loader_container').style.visibility='hidden';");
HttpContext.Current.Response.Write("}");
HttpContext.Current.Response.Write("</script>");
HttpContext.Current.Response.Write("<span id='loader_container' style='position:absolute; top:50%; left:50%'>");
HttpContext.Current.Response.Write("<img id='img' src='img/extanim32.gif' />"); //GIF图自己找个
HttpContext.Current.Response.Write("</span>");
HttpContext.Current.Response.Flush();
}
}
页面JS:
在Ext.onRead 方法的最后执行remove_loading()方法。
Ext.onReady(function(){
//其它代码
//最后隐藏等待图标
remove_loading();
});