C#.NET 等待畫面紀錄
在網頁後臺cs代碼:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ShowLoanding();
//.....
//你的資料載入代碼
Thread.Sleep(1000);//執行緒停留1秒,也可以不要。
}
}
//顯示載入進度
private void ShowLoanding()
{
Response.Write("<div style='position:absolute;z-index:600;width:expression(document.body.clientWidth);height:expression(document.body.clientHeight);background-color:#FFFFFF;text-align:center;padding-top:150px;' id='mydiv' >");
Response.Write("<img src='HTTP://www.kuwant.com/common/images/waiting.gif'> Loading...");
Response.Write("</div>");
Response.Write("<script language=javascript>;");
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();
}
在網頁aspx代碼<body>之後加入如下代碼:(目的隱藏等待效果)
padding: 0px" >
<script type="text/javascript">
HideWait();
</script>
沒有留言:
張貼留言