1.将ajax.dll下载并拷入文件夹,加成引用.
2.在web.config中加入
<httpHandlers>
<!-- Register the ajax handler -->
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
3.新建1个页面,取名sample.aspx后台加入
<1>private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Ajax.Utility.RegisterTypeForAjax(typeof(sample));
}
<2>写1个方法
[Ajax.AjaxMethod()]
public string test()
{
return " my test ajax";
}
4.前台建两个方法:
function goTest()
{
sample.test(getTest)
}
function getTest(res)
{
alert(res.value);
}
5.建1个按钮,调用goTest()就行了.

浙公网安备 33010602011771号