AjaxPro.Net的例子

AjaxPro.Net是一个优秀的.net环境下的ajax框架
.net 2.0对应的DLL为AjaxPro.2.dll,这个网上提供下载的地址很多。

一 环境
Windows 2003
VS 2005
AjaxPro 2

二 例子
1) 新建ASP.NET工程
2) 添加AjaxPro.2.dll
3) 修改WEB.CONFIG
4)新建一个页面ajaxpro.aspx,代码:

<% @ Page Language = " C# "  AutoEventWireup = " true "  CodeFile = " ajaxpro.aspx.cs "  Inherits = " ajaxpro "   %>

<! DOCTYPE html PUBLIC  " -//W3C//DTD XHTML 1.0 Transitional//EN "   " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml "   >
< head id = " Head1 "  runat = " server " >
    
< title > AjaxPro onLoading </ title >
</ head >
< body >
    
< form id = " form1 "  runat = " server " >
        
< div id = " loadinfo "  style = " visibility:hidden;position:absolute;left:0px;top:0px;background-color:Red;color:White; " > Loading </ div >
   
        
< input id = " Button1 "  type = " button "  value = " Get ServerTime "  onclick  = " javascript:GetTime();void(0) "   />

        
< script type = " text/javascript "  defer = " defer " >
        
        
//  loading效果
        AjaxPro.onLoading  =  function(b) 
        
{
            var a 
= document.getElementById("loadinfo");
            a.style.visibility 
= b ? "visible" : "hidden";
        }


        function GetTime() 
        
{
            
// 调用服务端方法
            
//调用方法:类名.方法名 (参数为指定一个回调函数)
            ajaxpro.GetServerTime(callback);
        }


        function callback(res)  
// 回调函数,显示结果
         {
            alert(res.value);
        }

        
</ script >
    
</ form >
</ body >
</ html >

5) 后台代码:
using  System;
using  System.Data;
using  System.Configuration;
using  System.Collections;
using  System.Web;
using  System.Web.Security;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.WebControls.WebParts;
using  System.Web.UI.HtmlControls;
using  AjaxPro;

public   partial   class  ajaxpro : System.Web.UI.Page
{
    
protected void Page_Load(object sender, EventArgs e)
    
{
        AjaxPro.Utility.RegisterTypeForAjax(
typeof(ajaxpro)); //注册ajaxPro,括号中的参数是当前的类名
    }


    [AjaxPro.AjaxMethod] 
//申明是ajaxPro方法
    public string GetServerTime()
    
{
        System.Threading.Thread.Sleep(
2000);
        
return DateTime.Now.ToString();
    }

}


三 测试
http://localhost:1966/WebSite2/ajaxpro.aspx

参考:
http://www.cnblogs.com/chy710/archive/2007/04/18/718715.html

      < httpHandlers >
      
< add verb = " POST,GET "  path = " ajaxpro/*.ashx "  type = " AjaxPro.AjaxHandlerFactory, AjaxPro " />
    
</ httpHandlers >
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值