2.配置web.config:
Code
3.配置全局应用程序
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
AjaxPro.Utility.HandlerPath = "ajaxpro";
}
protected void Application_End(object sender, EventArgs e)
{
}
}
{
protected void Application_Start(object sender, EventArgs e)
{
AjaxPro.Utility.HandlerPath = "ajaxpro";
}
protected void Application_End(object sender, EventArgs e)
{
}
}
4.使用:
后台代码:
要用AJAX方法的页page_load里加入注册
AjaxPro.Utility.RegisterTypeForAjax(typeof(ajax方法所在的类名));
这个注册方法是它自带的,实际的操作给源码加两条注册代码
Code
Plugins.MessageSystem.MessageCore指写ajax方法的类命名空间
MessageSystem指该项目的dll名
ajax方法编写(在上面提到的注册的类里)返回字符串
[AjaxPro.AjaxMethod]
// [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)] 这样可以操作session
public string Getdbdata()
{
return HttpContext.Current.Application["abc"].ToString();
}
// [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)] 这样可以操作session
public string Getdbdata()
{
return HttpContext.Current.Application["abc"].ToString();
}
前台脚本调用:
注册过的页面的脚本
function fun1()
{
var text=<注册过的ajax方法所在类>.<ajax方法()>.value;
alert(text);
}
{
var text=<注册过的ajax方法所在类>.<ajax方法()>.value;
alert(text);
}
ajax编写方法,返回集合:
Code
前台调用
Code