AjaxPro的应用

AjaxPro的应用
1、在项目中添加引用AjaxPro.2.dll
2、在web.config的httpHandlers节点里面添加
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
3.在要使用AjaxPro的页面类的加载事件中添加
AjaxPro.Utility.RegisterTypeForAjax(typeof(页面类名称));//注册AjaxPro
4、写要调用的方法。
[AjaxPro.AjaxMethod](这个特性标签标示AjaxPro可调用的方法)
例:
a.创建一个Demo.aspx页面
Demo.aspx.cs后台代码实例:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Demo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//注册AjaxPro
AjaxPro.Utility.RegisterTypeForAjax(typeof(Demo1));
}

[AjaxPro.AjaxMethod]//这个特性必须加,才能被前台调用
public string GetMessage(string name)
{
return "Hi" + name;
}
}
Demo.aspx.cs前台代码实例:

只列出主要部分
<script type="text/javascript">
function greet() {
var name = document.getElementById("txt").value;
var result = Demo1.GetMessage(name).value;//空间名+类名+方法名
document.getElementById("show").innerHTML = result;
}

</script>
<input type="text" id="txt" />
<input type="button" value="点击" onclick="greet()"/>
<div id="show"></div>

原文地址:https://www.cnblogs.com/SM88/p/4107728.html