关于asp.net PageMethod的 [英] Regarding PageMethod in asp.net

查看:121
本文介绍了关于asp.net PageMethod的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于PageMethods几个问题。我在学习使用PageMethod的的。

I have a few questions regarding PageMethods. I am learning the use of PageMethod.


  1. 为什么不能从PageMethods用户控件调用?

  2. 如果服务器端控件和视图状态无法从PageMethods访问,有什么用PageMethods的?如果我需要响应之后,更新使用JavaScript的UI从PageMethod的回来,那么我们就当我们与PageMethod的合作,编写大量脚本所有的时间。

所以,请告诉我,在什么样的情况,我们应该使用PageMethod的。

So please tell me in what kind of situation we should use PageMethod.

推荐答案

下面是一个PageMethod的的好处的一个简单的例子,通过功能的启发stackoverflow.com了。

Here is a simple example of the benefit of a PageMethod, inspired by functionality stackoverflow.com has.

当您在标签文本框中键入,搭配一些文字的标签,你开始进入开始出现。这可以在一个PageMethod的处理(尽管在这样的情况下,它不会,因为它们使用的网站上多个地方这个功能,因此它极有可能是它自己的Web服务)。无需额外的脚本:你只需调用PageMethod的在你的jQuery AJAX调用就像你除了网址为服务的任何其他Web服务,相同的页面(加上方法名)

When you type in the Tags textbox, tags that match some of the text you started to enter begin to appear. This could be handled in a PageMethod (although, in SO's case, it would not be, as they use this functionality in multiple places on the site, so it is very likely its very own web service). No extra scripting is needed: you simply call the PageMethod in your jQuery AJAX call like you would any other web service, except the URL for the service is the same as the page (plus the method name).

有关这方面的一个例子,请参见的http:// dotnetslackers .COM /用品/ AJAX /使用-jQuery的-与-ASP-NET.aspx

For an example of this, see http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx

这篇关于关于asp.net PageMethod的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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