高分求解无刷新信息提示 ( 积分: 100 )

  • 主题发起人 China_Wolf
  • 开始时间
C

China_Wolf

Unregistered / Unconfirmed
GUEST, unregistred user!
公司现在自用的一套OA系统(B/s),可以实现在线聊天。只要接收方在线,就会自动播放语音提示并显示出链接。。。。在asp.net2.0当中无法使用Timer控件。该功能是如何实现的???或给出思路
 
公司现在自用的一套OA系统(B/s),可以实现在线聊天。只要接收方在线,就会自动播放语音提示并显示出链接。。。。在asp.net2.0当中无法使用Timer控件。该功能是如何实现的???或给出思路
 
这个要用XMLHTTP来实现。不能用timer,因为那时服务器端的控件。
 
能否说得具体一些?
 
一个简单的例子:
ReturnXML.aspx文件内容
<%@ Page language=&quot;c#&quot;
Codebehind=&quot;ReturnXML.aspx.cs&quot;
AutoEventWireup=&quot;false&quot;
Inherits=&quot;Testonly.ReturnXML&quot;
%>
ReturnXML.aspx.cs文件内容
using 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;
using System.Text;
namespace Testonly
{
/// <summary>
/// ReturnXML 的摘要说明。
/// </summary>
public class ReturnXML : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// XmlDocument xmlDoc = new XmlDocument();
// xmlDoc.Load(Request.InputStream);
//这里可以取客户端Post过来的数据
//
// string sType = xmlDoc.SelectSingleNode(&quot;OilMIS/Code&quot;).Attributes.Item(0).Value;
// string sCanID = xmlDoc.SelectSingleNode(&quot;OilMIS/Code&quot;).Attributes.Item(1).Value;
StringBuilder sbXML = new StringBuilder();
//这里添加代码从数据库取数
sbXML.Append(string.Format(&quot;<Code tankNo='111' tankName='测试数据{0}' />&quot;,DateTime.Now.ToLongTimeString()));
//*********************************************
Response.ContentType = &quot;Text/Xml&quot;;
//Response.Write( &quot;<?xml version=/&quot;1.0/&quot;
encoding=/&quot;utf-8/&quot;
?> &quot;);
Response.Write (&quot;<OilMIS>&quot;);
Response.Write (sbXML.ToString());
Response.Write (&quot;</OilMIS>&quot;);
}
#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
}
}

另外一个HTMLPage1.htm:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<html>
<head>
<title></title>
<meta name=&quot;GENERATOR&quot;
content=&quot;Microsoft Visual Studio .NET 7.1&quot;>
<meta name=&quot;ProgId&quot;
content=&quot;VisualStudio.HTML&quot;>
<meta name=&quot;Originator&quot;
content=&quot;Microsoft Visual Studio .NET 7.1&quot;>
</head>
<body>
<script language=&quot;javascript&quot;>
<!--
function DataCommunicate(strXML,ActionFileURL)
{
var xmlDoc = new ActiveXObject(&quot;MSXML.DOMDocument&quot;);
xmlDoc.async = false;
strXML = &quot;<OilMIS>&quot;
+ strXML + &quot;</OilMIS>&quot;;
var httpObj = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
if(xmlDoc.loadXML(strXML))
{
httpObj.Open(&quot;POST&quot;,ActionFileURL,false);
httpObj.Send(xmlDoc);

if(xmlDoc.loadXML(httpObj.responseText)==false)
{
return &quot;<OilMIS>FALSE</OilMIS>&quot;;
}
else
{
return xmlDoc.xml;
}
}
}
function GetData()
{
var sReceiver = DataCommunicate(&quot;&quot;,&quot;ReturnXML.aspx&quot;);
var xmlDoc = new ActiveXObject(&quot;Msxml.DOMDocument&quot;);
alert(sReceiver);
xmlDoc.loadXML(sReceiver);
var nodelist = xmlDoc.selectNodes(&quot;OilMIS/Code&quot;);
alert(nodelist[0].attributes[1].value);
//return nodelist;
lblTest.innerHTML += nodelist[0].attributes[0].value + nodelist[0].attributes[1].value + &quot;<br>&quot;;
window.setTimeout(&quot;GetData();&quot;,6000);
}
window.setTimeout(&quot;GetData();&quot;,2000);
//-->
</script>
<span id=&quot;lblTest&quot;>

</span>
</body>
</html>
你浏览一下HTMLPage1.htm
 
接受答案了.
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
970
SUNSTONE的Delphi笔记
S
D
回复
0
查看
753
DelphiTeacher的专栏
D
顶部