




























因为我不可能写很大段使用文档,所以在这文章里只是告诉大家如何上手使用AjaxPro:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <httpHandlers> <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/> </httpHandlers> [...] </system.web> </configuration>
[AjaxPro.AjaxMethod]
public DateTime GetServerTime()
{
return DateTime.Now;
}
namespace MyDemo
{
public class _Default
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
}
[AjaxPro.AjaxMethod]
public DateTime GetServerTime()
{
return DateTime.Now;
}
}
}
function getServerTime()
{
MyDemo._Default.GetServerTime(getServerTime_callback); // asynchronous call
}
// 此方法执行后将调用下面的方法
// 结果将会返回给客户端
function getServerTime_callback(res)
{
alert(res.value);
}
- 你也可以在客户端使用JavaScript的同步方式来调用你的.net方法:
function getServerTime()
{
alert(MyDemo._Default.GetServerTime().value;
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。