如何使用asp.net web表单阿贾克斯 [英] How to use ajax with asp.net webforms

查看:243
本文介绍了如何使用asp.net web表单阿贾克斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用与asp.net web表单阿贾克斯我使用jQuery本),而无需通过网页生命周期中运行?

Is there any way to use ajax I'm using Jquery for this) with asp.net webforms without having to run through the pages life cycle?

推荐答案

如果你使用jQuery的,正如你所说,你可以的使用jQuery调用页面方法直接的,而不会产生MicrosoftAjax.js的开销,它所产生的服务代理启用 PageMethods.MethodName()语法。

If you're using jQuery, as you mentioned, you can use jQuery to call Page Methods directly, without incurring the overhead of MicrosoftAjax.js and the service proxy it generates to enable the PageMethods.MethodName() syntax.

由于静态 [的WebMethod] 在装饰方法 PageName.aspx 这就是所谓的方法名,这是你怎么称呼它在客户端的例子:

Given a static [WebMethod] decorated method in PageName.aspx that's called MethodName, this is an example of how you could call it on the client-side:

$.ajax({
  type: "POST",
  url: "PageName.aspx/MethodName",
  data: "{}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
    // Do something interesting with msg.d here.
  }
});

这篇关于如何使用asp.net web表单阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆