ASP.NET+Ajax+Javascript实现页面div定时刷新
一、概述
考虑Html本身不带定时刷新页面的控件,且不考虑使用第三方控件;因此考虑使用Javascript中的setTimeout+xmlhttp来实现定时更新页面中部分内容,此实现在IE6.0及以上版本测试通过,其他浏览器暂时未测试过。
二、功能及特点
1、Javascript通过Microsoft的MSXML对象,动态获取后台数据库数据;
2、Javascript解析MSXML对象中的xml内容,整理为html后,显示给用户;
3、Javascript实现分页功能;
4、通过配置文件Config.xml中的参数,可以修改div的刷新频率、每页显示记录条数等。
三、前台Html
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmBayonetShow.aspx.cs" Inherits="DynamicShow_FrmBayonetShow" %>
<!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>
</head>
<body>
<form id="FrmBayonetShow" runat="server">
<table id="BodyStyle" border="0px" width="100%">
<tr>
<td style="text-align: center; vertical-align: middle; font-family: 楷体_GB2312; font-size: 35px;
color: #0A246A; font-weight: bold; height: 50px">
页面动态更新示例
</td>
</tr>
<tr>
相关文档:
一,获得Mircosoft URLRewriter.dll:
获得Mircosoft URLRewriter.dll可以到http://www.microsoft.com/china/msdn/library/webservices/asp.net/URLRewriting.mspx?mfr=true
下载完毕后,导入工程,我这里没有对该工程做任何修改,保留了原来的重写方式,然后直接在VS2005里面生成.dll文件就可以了。
二,使用该dl ......
自定义控件中的页面代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="wcontrol.ascx.cs" Inherits="wcontrol" %>
<script type ="text/javascript">
function PopupCalendar(InstanceName)
{
///Global Tag
this.instanceName=InstanceName;
///Properties
this.separator="-"
t ......
需要用到第三方控件ICSharpCode.SharpZipLib.dll
using System.IO;
using System.IO.Compression;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Checksums;
#region 压缩文件夹,支持递归
/// <summary>
&nb ......
第一种方法:
通过URL链接地址传递
send.aspx:
protected void Button1_Click(object sender, EventArgs e)
{
Request.Redirect("Default2.aspx?username=honge");
&n ......
Several programming languages implement a sprintf function, to output a formatted string. It originated from the C programming language, printf function. Its a string manipulation function.
This is limited sprintf Javascript implementation. Function returns a string formatted by the usual printf co ......