如果你用的是.NET2.0,且不用VS2005的话。你只需要把AjaxPro.2.dll放入应用程序的bin文件夹中,而且也只需要如下几步:
1、修改web.config
在system.web节点下添加
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
2、将你的.NET方法添加AjaxMethod属性
[AjaxPro.AjaxMethod]
public DateTime GetServerTime()
{
return DateTime.Now;
}
============下面是我自己做的一个例子......完整,只说明了如何实现客户端访问服务端函数
1
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestAjaxPro.aspx.cs" Inherits="test_TestAjaxPro" %>
2
3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5
<html xmlns="http://www.w3.org/1999/xhtml" >
6
<head runat="server">
7
<title>无标题页</title>
8
<script type="text/javascript">
9
10
function getServerTime()
11
{
12
test_TestAjaxPro.GetServerTime(getServerTime_callback);
13
}
14
15
function getServerTime_callback(res)
16
{
17
alert(res.value);
18
}
19
20
</script>
21
</head>
22
<body>
23
<form id="form1" runat="server">
24
<div>
25
<input type="button" onclick="getServerTime();" value="测试AJAX PRO" />
26
</div>
27
</form>
28
</body>
29
</html>
30

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Collections;
5
using System.Web;
6
using System.Web.Security;
7
using System.Web.UI;
8
using System.Web.UI.WebControls;
9
using System.Web.UI.WebControls.WebParts;
10
using System.Web.UI.HtmlControls;
11
12
using AjaxPro;
13
14
public partial class test_TestAjaxPro : System.Web.UI.Page
15
{
16
protected void Page_Load(object sender, EventArgs e)
17
{
18
AjaxPro.Utility.RegisterTypeForAjax(typeof(test_TestAjaxPro)); //在.NET方法中向客户端注册javascript,用以javascript使用
19
}
20
21
[AjaxPro.AjaxMethod]
22
public string GetServerTime()
23
{
24
return "现在时间是:" + DateTime.Now;
25
}
26
27
}
28

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28
