我需要显示加载页面时加载GIF图像或使用jQuery和JavaScript进行回发期间长时间运行的任务或需要大量时间执行的进程。当页面加载(未提交事件)时显示加载进度图像
我试过这个解决方案,我没有错误,但加载没有显示。
我的代码如下。
我将不胜感激任何帮助,你可以给我解决这个问题。
的.cs
protected void Page_Load(object sender, EventArgs e)
{
string script = "$(document).ready(function());";
ClientScript.RegisterStartupScript(this.GetType(), "load", script, true);
System.Threading.Thread.Sleep(5000);
ExportToXLSFunction();
}
的.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="getData.aspx.cs" Inherits="getData"
EnableEventValidation="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="/jquery/js/jquery.min.js"></script>
<script type="text/javascript">
function ShowProgress() {
setTimeout(function() {
var modal = $('<div />');
modal.addClass("modal");
$('body').append(modal);
var loading = $(".loading");
loading.show();
var top = Math.max($(window).height()/2 - loading[0].offsetHeight/2, 0);
var left = Math.max($(window).width()/2 - loading[0].offsetWidth/2, 0);
loading.css({ top: top, left: left });
}, 200);
}
ShowProgress();
</script>
<style type="text/css">
.modal
{
position: fixed;
top: 0;
left: 0;
background-color: black;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}
.loading
{
font-family: Arial;
font-size: 10pt;
border: 5px solid #67CFF5;
width: 200px;
height: 100px;
display: none;
position: fixed;
background-color: White;
z-index: 999;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="loading" align="center">
Loading. Please wait.<br />
<br />
<img src="/images/wait01.gif" alt="" />
</div>
</form>
</body>
</html>
请任何教程? – Hamamelis
http://www.w3schools.com/jquery/ajax_ajaxstop.asp –
http://www.tutorialspoint.com/jquery/ajaxstop.htm这一个解释很好 –