a页面存入数据库,b页面读取数据库,c页面显示 用ajax做,可以做到吗?》 c先请求a,让a启动存入数据库程序。再请求b,b开始读取数据库,发送回c,c再用DOM是实时显示。可以做到吗?大家给点提示需要用多线程吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 概念性错误照你的叙述,只有c是一个页面,a和b都是业务层(或数据访问层)里的接口 我把代码贴出来webform1.aspx<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm1" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML><HEAD><title>WebForm1</title><script language="javascript">var XmlReq1,XmlReq2;var responseurl1 = "server.aspx",responseurl2 = "server2.aspx";function CreateXmlReq1(){try{XmlReq1 = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{XmlReq1 = new ActiveXObject("Microsoft.XMLHTTP");}catch(oc){XmlReq1 = null;}}if(!XmlReq1 && typeof XMLHttpRequest != "undefined") {XmlReq1 = new XMLHttpRequest();}}function CreateXmlReq2(){try{XmlReq2 = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{XmlReq2 = new ActiveXObject("Microsoft.XMLHTTP");}catch(oc){XmlReq2 = null;}}if(!XmlReq2 && typeof XMLHttpRequest != "undefined") {XmlReq2 = new XMLHttpRequest();}}function onloada(){//alert("onloada");document.Form1.txt1.value = "wwww";CreateXmlReq1();if(XmlReq1){XmlReq1.onreadystatechange = Res1;XmlReq1.open("get",responseurl1,true);XmlReq1.send();}window.setInterval(test2,2000);}function Res1(){if( XmlReq1.readyState == 4){if( XmlReq1.status == 200){}}}function test2(){CreateXmlReq2();XmlReq2.onreadystatechange = Res2;XmlReq2.open("get",responseurl2,true);XmlReq2.send();}function Res2(){if( XmlReq2.readyState == 4){if( XmlReq2.status == 200){document.Form1.txt1.value += XmlReq2.responseText;}}}</script><meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"><meta name="CODE_LANGUAGE" Content="C#"><meta name="vs_defaultClientScript" content="JavaScript"><meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"></HEAD><body MS_POSITIONING="GridLayout" onload="onloada()"><form id="Form1" method="post" runat="server"><table id="Table1"><tbody></tbody></table><INPUT id="txt1" style="Z-INDEX: 101; LEFT: 280px; POSITION: absolute; TOP: 264px" type="text"></form></body></HTML>server.aspx.csusing System;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;namespace test{/// <summary>/// server 的摘要说明。/// </summary>public class server : System.Web.UI.Page{private void Page_Load(object sender, System.EventArgs e){// 在此处放置用户代码以初始化页面int i = 0;for(i = 0; i < 10; i ++){//Application.Lock();Application["test"] = i;//Application.UnLock();System.Threading.Thread.Sleep(500);}}#region Web 窗体设计器生成的代码override protected void OnInit(EventArgs e){//// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。//InitializeComponent();base.OnInit(e);}/// <summary>/// 设计器支持所需的方法 - 不要使用代码编辑器修改/// 此方法的内容。/// </summary>private void InitializeComponent(){ this.Load += new System.EventHandler(this.Page_Load);}#endregion}}server1.aspx.csusing System;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;namespace test{/// <summary>/// server2 的摘要说明。/// </summary>public class server2 : System.Web.UI.Page{private void Page_Load(object sender, System.EventArgs e){// 在此处放置用户代码以初始化页面//Application.Lock();int i = (int)Application["test"];//Application.UnLock();//Response.Clear();Response.ContentType = "text/xml";Response.Write(i.ToString());Response.End();}#region Web 窗体设计器生成的代码override protected void OnInit(EventArgs e){//// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。//InitializeComponent();base.OnInit(e);}/// <summary>/// 设计器支持所需的方法 - 不要使用代码编辑器修改/// 此方法的内容。/// </summary>private void InitializeComponent(){ this.Load += new System.EventHandler(this.Page_Load);}#endregion}}这些代码可以执行,我想要的效果是server.aspx.cs循环时,i增加1,webform1的input里面就增加一个数字,多谢大家 我换成把server.aspx.cs生成的数据写入数据库,再用server1.aspx.cs读出来显示也不行,各位有什么好的办法没有?注意,在server1读取数据的时候,server是在不断往数据库里写入的 上面的代码是我自己写的啊,哥哥门,呵呵用那些代码实现不了的,主要是server1是在不断往数据库里写东西的,server2总会在server1执行完了以后才会执行的 ★这样的导出Excel乱码问题就不能解决吗? 随机函数问题 asp.net关于框架的几个问题! asp.net UI控件库 数据库问题 高手进来!!! 在ExtAspNet或者FineUI里,怎么弹出提示框后再跳转到指定页面? 看看小弟在搞的一个网站 http://www.uphoto.net/Login.aspx 请教这是什么原因? 带有用户控件的页面刷新问题 各位老大,我在aspx中使用的web控件运行后在ie6.0中不见了,以前在低版本的ns中才会出现! 问一个关于CSS的问题 关于网站rewrite后纯html页不能访问的问题
webform1.aspx
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<script language="javascript">
var XmlReq1,XmlReq2;
var responseurl1 = "server.aspx",responseurl2 = "server2.aspx";
function CreateXmlReq1()
{
try
{
XmlReq1 = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
XmlReq1 = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc)
{
XmlReq1 = null;
}
}
if(!XmlReq1 && typeof XMLHttpRequest != "undefined")
{
XmlReq1 = new XMLHttpRequest();
}
}
function CreateXmlReq2()
{
try
{
XmlReq2 = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
XmlReq2 = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc)
{
XmlReq2 = null;
}
}
if(!XmlReq2 && typeof XMLHttpRequest != "undefined")
{
XmlReq2 = new XMLHttpRequest();
}
}
function onloada()
{
//alert("onloada");
document.Form1.txt1.value = "wwww";
CreateXmlReq1();
if(XmlReq1)
{
XmlReq1.onreadystatechange = Res1;
XmlReq1.open("get",responseurl1,true);
XmlReq1.send();
}
window.setInterval(test2,2000);
}
function Res1()
{
if( XmlReq1.readyState == 4)
{
if( XmlReq1.status == 200)
{}
}
}
function test2()
{
CreateXmlReq2();
XmlReq2.onreadystatechange = Res2;
XmlReq2.open("get",responseurl2,true);
XmlReq2.send();}
function Res2()
{
if( XmlReq2.readyState == 4)
{
if( XmlReq2.status == 200)
{
document.Form1.txt1.value += XmlReq2.responseText;
}
}
}</script>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout" onload="onloada()">
<form id="Form1" method="post" runat="server">
<table id="Table1">
<tbody>
</tbody>
</table>
<INPUT id="txt1" style="Z-INDEX: 101; LEFT: 280px; POSITION: absolute; TOP: 264px" type="text">
</form>
</body>
</HTML>server.aspx.csusing System;
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;namespace test
{
/// <summary>
/// server 的摘要说明。
/// </summary>
public class server : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
int i = 0;
for(i = 0; i < 10; i ++)
{
//Application.Lock();
Application["test"] = i;
//Application.UnLock();
System.Threading.Thread.Sleep(500);
}
}#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
server1.aspx.csusing System;
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;namespace test
{
/// <summary>
/// server2 的摘要说明。
/// </summary>
public class server2 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
//Application.Lock();
int i = (int)Application["test"];
//Application.UnLock();
//Response.Clear();
Response.ContentType = "text/xml";
Response.Write(i.ToString());
Response.End();
}#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}这些代码可以执行,我想要的效果是server.aspx.cs循环时,i增加1,webform1的input里面就增加一个数字,
多谢大家
注意,在server1读取数据的时候,server是在不断往数据库里写入的
用那些代码实现不了的,
主要是server1是在不断往数据库里写东西的,server2总会在server1执行完了以后才会执行的