用链接的方式打开一个页面,该页面负责加载数据,怎么实现等待加载数据的过程显示“数据加载中”用asp.net 的ajax 中的updatepanel+progress控件是可以实现的,但是只能在本页通过按钮的触发方式才能实现现在用的是链接,打开一个新页面,怎么办?有的人用一个页面显示数据加载中,过几秒在跳转的方式,但是不想用这种假的 数据加载中 的方式
希望能等同updatepanel+progress控件那样
怎么写这个ajax呢?希望能详细点,不要一句话带过
希望能等同updatepanel+progress控件那样
怎么写这个ajax呢?希望能详细点,不要一句话带过
PageProcessor.aspx(进度页)<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PageProcessor.aspx.cs" Inherits="PageProcessor" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
var iLoopCounter = 1;
var iMaxLoop = 6;
var iIntervalId;
function BeginPageLoad()
{
// Redirect the browser to another page while keeping focus.
location.href = "<%=PageToLoad %>";
// Update progress meter every 1/2 second.
iIntervalId = window.setInterval("iLoopCounter=UpdateProgressMeter(iLoopCounter,iMaxLoop);", 500);
}
function EndPageLoad()
{
window.clearInterval(iIntervalId); // Find the object that represents the progress meter.
var progressMeter = document.getElementById("ProgressMeter")
progressMeter.innerHTML = "Page Loaded - Now Transfering";
}
function UpdateProgressMeter(iCurrentLoopCounter, iMaximumLoops)
{
var progressMeter = document.getElementById("ProgressMeter")
iCurrentLoopCounter += 1;
if(iCurrentLoopCounter <= iMaximumLoops)
{
progressMeter.innerHTML += ".";
return iCurrentLoopCounter;
}
else
{
progressMeter.innerHTML = "";
return 1;
}
}
</script>
</head>
<body onload="BeginPageLoad();" onunload="EndPageLoad();"> <form id="form1" runat="server">
<div>
<table border="0" width="99%">
<tr>
<td align="center" valign="middle">
<span id="MessageText" style="font-size:x-large; font-weight:bold">Loading Page - Please Wait</span>
<span id="ProgressMeter" ></span>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>PageProcessor.aspx.csusing System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class PageProcessor : System.Web.UI.Page
{
protected string PageToLoad; protected void Page_Load(object sender, System.EventArgs e)
{
PageToLoad = Request.QueryString["Page"];
}}
PageProcessor_Start.aspx(原始页)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PageProcessor_Start.aspx.cs" Inherits="PageProcessor_Start" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button id="cmdGo" runat="server" Text="Go" OnClick="cmdGo_Click"></asp:Button>
</div>
</form>
</body>
</html>
PageProcessor_Start.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class PageProcessor_Start : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void cmdGo_Click(object sender, EventArgs e)
{
Server.Transfer("PageProcessor.aspx?Page=PageProcessor_Target.aspx");
}
}PageProcessor_Target.aspx (略执行较长时间的那个页)
PageProcessor_Target.aspx.cs(略)http://www.mybuffet.cn
是在新页面加载中,还是在本页显示加载中还有链接是target=_blank 还是window.open同不同域??如果是window.open可以用在弹出页执行到加载完毕以后window.opener.document.getElementById("divid").style.display="none";这样的方式解决....