本文介绍ajax.net 1.0用法
1、首先现在一个Ajax.dll文件,添加到项目引用中
2、在页面page_load中添加
//注册Ajax,其中Test为Page的类名
Ajax.Utility.RegisterTypeForAjax(typeof(Test));
3、在页面的cs文件中写后台调用方法
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public string getCity()
{
return "ss";
}
4、前台js调用
<script type="text/javascript">
function ajaxtest() {
Test.getCity(ajaxtest_CallBack);
}
//后台方法完成后页面的回调方法
function ajaxtest_CallBack(response) {
if (response.error != null) {
//我们应该能做得更好
alert(response.error);
return;
}
var states = response.value;
alert(states);
}
</script>