Chinaunix首页 | 论坛 | 博客
  • 博客访问: 80524
  • 博文数量: 64
  • 博客积分: 1545
  • 博客等级: 上尉
  • 技术积分: 392
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-23 15:23
文章分类

全部博文(64)

文章存档

2013年(1)

2012年(63)

我的朋友

分类: 嵌入式

2012-11-09 16:21:19

从客户端调用后台静态方法 1.Ajax Library方式

C#代码:

 [WebMethod]
    public static DateTime GetCurrentTime()
    {
        return DateTime.Now;
    }

JS代码:
  function GetCurrentTime1() {
        PageMethods.GetCurrentTime( CheckIsSuccess);
    }
    function CheckIsSuccess(result) {
        alert(result);
    }
EnablePageMethods="true">
   
   
       

C#方法必须加 "[WebMethod]"

前台页面必须使用引用 服务器控件


调用方法: PageMethods.后台方法名(参数[,参数....], 成功后调用的方法名);

http://www.cnblogs.com/henw/archive/2012/05/03/2480415.html

2. jQuery方式

http://blog.chinaunix.net/uid-28299820-id-3403095.html


阅读(470) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~