我在应用程序中放置了一个button,点击后是对某个数据库中的指定表逐条记录进行处理,我想在页面上放一个label或span,每处理完一条记录就反映处理的过程,比如说“数据正在处理,请稍侯... 当前正在处理第 5 条记录,共 2350 条”。
赋值给label或span都很简单,但页面不能反映最新的情况,直到处理完成后才显示
"数据正在处理,请稍侯... 当前正在处理第 2350 条记录,共 2350 条"
有什么办法让页面在每处理完一条记录后刷新一次,但不影响处理过程。
赋值给label或span都很简单,但页面不能反映最新的情况,直到处理完成后才显示
"数据正在处理,请稍侯... 当前正在处理第 2350 条记录,共 2350 条"
有什么办法让页面在每处理完一条记录后刷新一次,但不影响处理过程。
解决方案 »
- 动态绑定树形控件问题?
- CSS问题
- m_CustomerList m_customerList which one is best normalise?
- repeater里checkbox值问题
- 为什么先前保存的会话状态始终无法读出来?
- window.status怎么我浏览器没显示出来呀?
- 求助:ASP.NET和EXCEL问题
- 寻找一个控件
- 一个关于SharePoint,服务器端控件,xml+xsl的问题?
- modalpopupanimationextender
- 时间比较的问题(如10:00 <11:00)js 怎么写
- [求救]FCKeditor_2.2(net1.1)中,上传的图片名称不支持中文,而且容易重复,怎么解决?
}Process
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using ERP.Operation.PublicAction;namespace GoldInfo.ERP.PublicAction
{
/// <summary>
/// BuildPlan 的摘要说明。
/// BuildPlan.aspx?nd yf ddlx jhlx type {1 发交计划,2 分厂发交计划,3 销售计划,4 主生产发交计划,5 审核},bbh,bbh2
/// </summary>
public class BuildPlan : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Msg;
protected System.Web.UI.WebControls.Button Config;
protected System.Web.UI.WebControls.Button Canel;
private BuildWork work;
private string nd,yf,ddlx,bbh,type,jhlx,bbh2,action;
private void Page_Load(object sender, System.EventArgs e)
{
Response.Expires = 0;
//AjaxPro.Utility.RegisterTypeForAjax(typeof(SaleOrder01BuildPlan));
//隐藏按扭
this.Config.Visible = false;
this.Canel.Visible = false; //获取参数
nd = Request["nd"] + "";
yf = Request["yf"] + "";
ddlx = Request["ddlx"] + "";
bbh = Request["bbh"] + "";
type = Request["type"] + "";
jhlx = Request["jhlx"] + "";
bbh2 = Request["bbh2"] + "";
action = Request["action"] + ""; if(Session["work"] == null)
{
if(nd.Equals("") || yf.Equals("") || ddlx.Equals("") || type.Equals(""))
{
Response.Write("缺少页面参数!");
Response.End();
}
string czr = UserAction.GetUser();
work = new BuildWork(action,nd,yf,ddlx,jhlx,bbh,bbh2,czr,type);
Session["work"] = work;
}
else
{
work = (BuildWork)Session["work"];
} switch(work.GetState)
{
case 0:
{
this.Msg.Text = "数据确认:" + nd + "年" + yf + "月 订单类型 " + ddlx + " 版本 " + bbh;
this.Config.Visible = true;
this.Canel.Visible = true;
this.Canel.Attributes["onclick"] = "javascript:CloseWindow(false);return false;";
break;
}
case 1:
{
this.Msg.Text = "<center>请稍候该操作正在处理中,用时 " + ((TimeSpan)(DateTime.Now - work.StartDate)).TotalSeconds.ToString("0.00") + " 秒</center>";
this.Config.Visible = false;
this.Canel.Visible = false;
Page.RegisterStartupScript("","<script>LoadPage();</script><script>GetObj('Content').style.cursor = 'hand';</script>");
break;
}
case 2:
{
this.Msg.Text = "<center>该操作已成功生成,耗时 " + ((TimeSpan)(work.FinishDate - work.StartDate)).TotalSeconds.ToString("0.00") + " 秒</center>";
this.Canel.Text = "关闭窗口";
this.Canel.Visible = true;
this.Config.Visible = false;
RemoveState(); this.Canel.Attributes["onclick"] = "javascript:CloseWindow(true);return false;";
break;
}
case 3:
{
this.Msg.Text = "<B>错误:</B><font color=red>" + work.GetMsg + "</font>";
this.Canel.Visible = true;
RemoveState();
this.Canel.Text = "关闭窗口";
this.Config.Visible = false;
this.Canel.Attributes["onclick"] = "javascript:CloseWindow(false);return false;";
break;
}
} } //[AjaxPro.AjaxMethod]
public void RemoveState()
{
Session.Remove("work");
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Config.Click += new System.EventHandler(this.Config_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Config_Click(object sender, System.EventArgs e)
{
if(work.GetState != 1)
{
this.Config.Visible = false;
this.Canel.Visible = false;
work.StartWork();
Page.RegisterStartupScript("","<script>LoadPage();</script>");
}
}
} public class BuildWork
{
private string nd,yf,ddlx,bbh,type,czr,jhlx,bbh2,action;
private int State = 0;
private string Msg = "";
private DateTime startTime,finishTime; public string GetMsg
{
get{return Msg;}
} public int GetState
{
get{return this.State;}
} public DateTime StartDate
{
get{return this.startTime;}
} public DateTime FinishDate
{
get{return this.finishTime;}
} public BuildWork(string _action,string _nd,string _yf,string _ddlx,string _jhlx,string _bbh,string _bbh2,string _czr,string _type)
{
action = _action;
nd = _nd;
yf = _yf;
ddlx = _ddlx;
bbh = _bbh;
type = _type;
czr = _czr;
jhlx = _jhlx;
bbh2 = _bbh2;
} public void StartWork()
{
lock(this)
{
if(State != 1)
{
State = 1;
startTime = DateTime.Now; System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(TranBuild)); thread.Start();
}
}
} private void TranBuild()
{
try
{
BuildPlans build = new BuildPlans(); string Err = "";
if(build.BuildPlan(action,nd,yf,ddlx,jhlx,bbh,bbh2,czr,type,out Err))
{
State = 2;
Msg = "此版计划已成功生成!";
}
else
{
State = 3;
Msg = Err;
}
}
catch(Exception ex)
{
string Err = ex.Message;
State = 3;
Msg = "数据错误,请先检查原数据,或重新登录尝试!";
}
finally
{
finishTime = DateTime.Now;
}
}
}
}
下面这个例子是我查看一条消息显示的纪录
<td style="cursor:pointer" onclick="UpdateMessage(<%# Eval("id")%>)">
<div id='div<%# Eval("id") %>'></div>
</td>function UpdateMessage(theID)
{
var ss="div"+theID;
var obj=document.getElementById(ss);
News.UpdateIsReaded(theID); //ajax调用后台方法进行更新操作
obj.innerHTML="消息已察看..." ;
obj.style.color="dd5699";
}