日期:2014-05-16 浏览次数:20611 次
前台页面:
?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Manage.Web.test" %> <!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> <span id="myid"></span> <form id="form1" runat="server" method="post" > <div> <script> function test() { TestAjax.ttt(); procs(); } function procs() { TestAjax.procs(getStr); } function getStr(res) { if (res.value != null ) { document.getElementById("myid").innerHTML = res.value +"<br/>"; setTimeout("procs()",500); } } </script> </div> <input type="button" value="test" onclick="test();"/> </form> </body> </html>
?
?
后台:
?
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using AjaxPro; using System.Text; using System.Threading; namespace Manage.Web { [AjaxNamespace("TestAjax")] public partial class test : System.Web.UI.Page { public static string txt = ""; protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(test)); } [AjaxPro.AjaxMethod()] public void ttt() { System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(calculate)); thread.Start(); } [AjaxPro.AjaxMethod()] public string procs() { if (txt != null) { return txt; } return string.Empty; } public void calculate() { for (int i = 0; i < 10; i++) { txt += "测试进度条" + i + "<br/>"; Thread.Sleep(1000); } } } }
?
?
?
至于ajaxpro在asp.net中配置就不用说了,这个都知道的