AjaxPro.Net是一个优秀的.net环境下的Ajax框架,用法很简单,可以查阅相关资料,下面一个简单的实例讲述使用AjaxPro的几个关键点(注意,必须有AjaxPro包,即AjaxPro.dll文件,可以在VSS上下载)。
首先我们要 AjaxPro包,并将AjaxPro.dll 拷到项目的bin下面
在web.config中配置如下,添加以下代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
< location path = " ajaxpro " > < system.web > < httpHandlers > < add verb = " * " path = " *.ashx " type = " AjaxPro.AjaxHandlerFactory,AjaxPro.2 " /> </ httpHandlers > </ system.web > </ location >
其次,我们来添加一个服务器端的方法
protected void Page_Load( object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax( typeof (AjaxDemo)); } [AjaxPro.AjaxMethod] public string Getinfo( string aa) { return aa; }
上面有几点需要说明的是
首先,访问修饰符public
其次,在方法的上面要加上 [AjaxPro.AjaxMethod]
最后在加载页面的时候要加上 AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxDemo)); 注意AjaxDemo是页面类的名称
最后在前台页面中调用后台的方法
< script type = " text/javascript " > function AjaxDemo1() { var ajaxValue = AjaxDemo.Getinfo( " 把我打印出来吧 " ).value; alert(ajaxValue); } </ script >
调用后台的方式,在不刷新页面的情况下输入内容
可以用来验证用户名重复等问题....