本文介绍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>
本文详细介绍了如何使用Ajax.NET 1.0进行前后端交互,包括添加Ajax.dll引用、注册Ajax、编写后台调用方法及前端JS调用步骤。
508

被折叠的 条评论
为什么被折叠?



