AjaxPro 框架学习 (支持vs2003/vs2005)

本文介绍如何使用 AjaxPro 在 .NET 应用中实现异步方法调用。通过配置 Web.config 和编写简单的 C# 代码,可以轻松创建异步调用的功能。文章还提供了具体的代码示例,包括 Web.config 的配置、C# 后端方法定义及 ASP.NET 页面调用方式。

AjaxPro 相关资类
Web配制

<?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;
}

页面CS

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;
    }
  }
}

页面aspx

 

function getServerTime()
{
MyDemo._Default.GetServerTime(getServerTime_callback);  // asynchronous call
}
// This method will be called after the method has been executed
// and the result has been sent to the client.
function getServerTime_callback(res)
{
alert(res.value);
}
简单吧!可以支持vs2003/vs2005
 

转载于:https://www.cnblogs.com/sgciviolence/archive/2008/08/07/1263277.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值