在我我的博客里有ajaxpro 的插件 下载完自己 引用 dll
首先在Config 里面配置
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
界面上
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="AjaxTest.test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
function OnButtonClick() {
alert(AjaxTest.test.TestA().value);
alert(AjaxTest.test.Add(1, 2).value);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="btn" onclick="OnButtonClick()" type="button" value="Ajax调用服务器方法" />
</div>
</form>
</body>
</html>
using AjaxPro;
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace AjaxTest
{
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Utility.RegisterTypeForAjax(typeof(test));//注册当前页面的 名称
}
/// <summary>
/// 调用的类 添加 特性类
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
[AjaxMethod]
public int Add(int a, int b)
{
return a + b;
}
[AjaxMethod]
public string TestA()
{
return DateTime.Now.ToString();
}
}
}
ajaxpro2 调用后台的方法 ajax获取后台的值 ajaxpro2 调用后台的方法 ajax获取后台的值
下载当前例子http://download.youkuaiyun.com/detail/a770kfof/9651523