后台进行处理,给aspx页面加提示“正在处理中。。。”

bl_song 2009-11-25 02:32:26
我前台页面有一个按钮<asp:Button ID="Button1" CssClass="Button" runat="server" OnClick="Button1_Click" Text=" 确 定 " /> 点击这个按钮后,后台进行一个处理,处理时间比较长,想在后台处理过程中,让前台aspx页面显示一个提示信息“正在处理中。。。”

如何能够实现进度显示,那就更好(+20)!



...全文
617 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyjcel 2009-11-26
  • 打赏
  • 举报
回复
这么多都还不够!!!!
namhyuk 2009-11-26
  • 打赏
  • 举报
回复
最最简单的方法就是拖一个UpdateProgress,里面放一个动画gif了。配合UpdatePanel,这里几乎没什么技术涵量,就是拖~

当然你也可以处理Microsoft Ajax的客户端框架的PageRequestManager的initializeRequest,beginRequest, pageLoadign, pageLoaded,endRequest等事件,细化异步过程中的提示。
bl_song 2009-11-26
  • 打赏
  • 举报
回复
楼上是用asp.net ajax,有没有完整的例子!
bl_song 2009-11-26
  • 打赏
  • 举报
回复
好了,结贴!
wuyq11 2009-11-25
  • 打赏
  • 举报
回复
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upl" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div>
<div>数据加载中,请等待…… </div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:UpdatePanel>

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID ="Button1" EventName ="Click" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"> </asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<span style =" font-size:12px">数据更新中...... </span>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:Button ID="Button1" runat="server" Text="Button" Width="143px" OnClick="Button1_Click" />
或使用div显示loading效果
<script language="javascript" type="text/javascript">
document.write(" <div id='loadDiv' style='padding-top: 250px; padding-left: 350px;font-size:x-large;height:400px'> <span id='loading'> <img src=\"../Images/loader2.gif\"/>正在加载数据,请稍候··· </span> </div>");
window.onload = function()
{
document.getElementById("hiddenDiv").style.display="";
document.getElementById("loadDiv").parentNode.removeChild(document.getElementById("loadDiv"));

}
</script>
http://topic.csdn.net/u/20090330/14/884d2efe-cffc-4ad6-ab21-d7a8eeb1dc14.html
  • 打赏
  • 举报
回复
^_^
bl_song 2009-11-25
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 aperson111 的回复:]
如果是asp的服务器控件button的话,就要用 onclientclick="creatReq()";响应前台js函数
然后再onclick中响应后台c#事件
[/Quote]
加上onclientclick="creatReq()";后,页面还是不显示 ”数据加载中“
您能不能帮我把上面的例子改一下?
aperson111 2009-11-25
  • 打赏
  • 举报
回复
如果是asp的服务器控件button的话,就要用 onclientclick="creatReq()";响应前台js函数
然后再onclick中响应后台c#事件
bl_song 2009-11-25
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 ws_hgo 的回复:]
http://blog.csdn.net/ws_hgo/archive/2009/07/28/4388800.aspx
[/Quote]
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>xmlhttprequest ajax demo</title>
<script type ="text/javascript" language ="javascript" >
var req; //定义变量,用来创建xmlhttprequest对象
function creatReq() // 创建xmlhttprequest,ajax开始
{
var url="ajaxServer.aspx"; //要请求的服务端地址
if(window.XMLHttpRequest) //非IE浏览器及IE7(7.0及以上版本),用xmlhttprequest对象创建
{
req=new XMLHttpRequest();
}
else if(window.ActiveXObject) //IE(6.0及以下版本)浏览器用activexobject对象创建,如果用户浏览器禁用了ActiveX,可能会失败.
{
req=new ActiveXObject("Microsoft.XMLHttp");
}

if(req) //成功创建xmlhttprequest
{
req.open("GET",url,true); //与服务端建立连接(请求方式post或get,地址,true表示异步)
req.onreadystatechange = callback; //指定回调函数
req.send(null); //发送请求
}
}

function callback() //回调函数,对服务端的响应处理,监视response状态
{
if(req.readystate==4) //请求状态为4表示成功
{
if(req.status==200) //http状态200表示OK
{
Dispaly(); //所有状态成功,执行此函数,显示数据
}
else //http返回状态失败
{
alert("服务端返回状态" + req.statusText);
}
}
else //请求状态还没有成功,页面等待
{
document .getElementById ("myTime").innerHTML ="数据加载中";
}
}

function Dispaly() //接受服务端返回的数据,对其进行显示
{
document .getElementById ("myTime").innerHTML =req.responseText;
}

</script>
</head>
<body>
<div id="myTime"></div>

<input id="Button1" type="button" value="Get Time" onclick ="creatReq();"/>
</body>
</html>

其中
<input id="Button1" type="button" value="Get Time" onclick ="creatReq();"/>

这里如何改为
<asp:Button id="Button1" runat="server" OnClick="creatReq();"/>
就出错了,如何做?
whatisma 2009-11-25
  • 打赏
  • 举报
回复
用Ajax加上遮罩层这样貌似挺好的
SK_Aqi 2009-11-25
  • 打赏
  • 举报
回复
正解!
ws_hgo 2009-11-25
  • 打赏
  • 举报
回复
http://blog.csdn.net/ws_hgo/archive/2009/07/28/4388800.aspx
shinyML 2009-11-25
  • 打赏
  • 举报
回复
都是精华啊
阿非 2009-11-25
  • 打赏
  • 举报
回复
public String GetSessionValue()
{
if (Session["a"] != null)
return "页面正在处理中。。。";
else
return "处理已完成";
}
bl_song 2009-11-25
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 sandy945 的回复:]

[/Quote]
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
public String GetSessionValue()
{
if (Session["a"] != null) return Session["a"].ToString();
else return "-----";
}
可不可以改为:
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
public String GetSessionValue()
{
return "页面正在处理中。。。";
}
阿非 2009-11-25
  • 打赏
  • 举报
回复


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;
using System.Reflection;
using System.Xml;
using System.Data.SqlClient;

using System.Messaging;
using System.Text.RegularExpressions;
using System.Net;
using System.Data.OleDb;

[AjaxPro.AjaxNamespace("AJ")]
public partial class ajax_ajaxpro_MultiThread : System.Web.UI.Page
{
System.Web.SessionState.HttpSessionState _Session;
protected void Page_Load(object sender, EventArgs e)
{
Response.Expires = -100;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
AjaxPro.Utility.RegisterTypeForAjax(typeof(ajax_ajaxpro_MultiThread), this);


}


[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
public String GetSessionValue()
{
if (Session["a"] != null) return Session["a"].ToString();
else return "-----";
}
protected void Button1_Click(object sender, EventArgs e)
{

Session["a"] = "0";
System.Threading.Thread NewTh = new System.Threading.Thread(new System.Threading.ThreadStart(this.Update));

NewTh.Start();


ClientScript.RegisterStartupScript(this.GetType(), "a", "window.setInterval(showvalue, 1000);", true);


}

void Update()
{

try
{

Session["a"] = "10";
System.Threading.Thread.Sleep(3000);
Session["a"] = "30";
System.Threading.Thread.Sleep(3000);
Session["a"] = "50";
System.Threading.Thread.Sleep(3000);
Session["a"] = "80";
System.Threading.Thread.Sleep(3000);
Session["a"] = "100";
System.Threading.Thread.Sleep(3000);

}
catch
{ }
}



}




AjaxPro.dll
zhangle1987 2009-11-25
  • 打赏
  • 举报
回复
阿非 2009-11-25
  • 打赏
  • 举报
回复



<!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>
<style>
*
{
font:menu;
}



.CalendarArrow
{
CURSOR: pointer;font-weight:bold;
}
</style>



<script type="text/javascript">

function showvalue()
{

document.getElementById('div1').innerHTML= AJ.GetSessionValue().value;
}

</script>

</head>

<body >

<form id="form1" runat="server">


<asp:Button ID="btnNext" runat="server" Text="确定" OnClick="Button1_Click" />


<div id="div1"> </div>
</form>


</body>
</html>

bl_song 2009-11-25
  • 打赏
  • 举报
回复
有完整的例子吗?
randomfeel 2009-11-25
  • 打赏
  • 举报
回复
弄个div ,div的id=msg
加载更多回复(6)

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧