惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
博客园_首页
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
The Cloudflare Blog
罗磊的独立博客
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog
Last Week in AI
Last Week in AI
J
Java Code Geeks
MyScale Blog
MyScale Blog
G
Google Developers Blog
U
Unit 42
Y
Y Combinator Blog
P
Proofpoint News Feed
Vercel News
Vercel News

博客园 - KevinWang

Server.HtmlEncode vs HttpUtility.HtmlEncode 在FireFox IE 下Response 中文文件名乱码问题 序列化,反序列化时低序位非打印 ASCII 字符的问题 - KevinWang 月薪上万的人都懂得这些道理 c# .ToString()格式化 利用ListView和DataPager控件来对数据分页 (转) asp.net中使用ajax中的三种方式 Asp.Net2.0技巧 - KevinWang - 博客园 虚方法(virtual)和抽象方法(abstract)的区别 数据库设计经验之谈(转载) 网站令浏览器崩溃的原因 各种流行的编程风格 2009年海外Web设计风潮 常用js框架,js库 硬盘RAID是什么意思?有什么用? T-SQL和PL/SQL 区别 What is PL/SQL?(PL/SQL是什么,与T-SQL对比) 数据库和数据仓库的区别 ASP.NET MVC 资料
PageMethods Not Found (or Defined)?
KevinWang · 2010-04-23 · via 博客园 - KevinWang

If you are seeing this javascript error (or similar) while trying to use Page Methods with ASP.NET AJAX, here is a checklist that should save you some time.

  1. The page method must have the System.Web.Services.WebMethod attribute.
    [WebMethod]
    ...
  2. The page method must be public.
    [WebMethod]
    public ...
  3. The page method must be static.
    [WebMethod]
    public static ...
  4. The page method must be defined on the page (either inline or in the code-behind).  It cannot be defined in a control, master page, or base page.
    <%@ Page Language="C#" %>
    <script runat="server">
    [WebMethod]
    public static ...
  5. The ASP.NET AJAX Script Manager must have EnablePageMethods set to true.
    <asp:ScriptManager EnablePageMethods="true" For an example with full source see Calling static methods in an ASP.NET Web Page.
  6. [Reader Tip] If all else fails, be sure you are seeing the correct error.  A reader kindly reported that although they saw the "PageMethods not defined" error, the server-side code was still executing correctly.  After switching to FireFox, they discovered the real error.  Perhaps Firebug would also be quite useful while tracking down such scandalous errors. [Thank JohnL for the tip] 
    Note that you can use complex return types and parameters with page methods the same as with calling web services with ASP.NET AJAX.

posted @ 2010-04-23 11:02  KevinWang  阅读(396)  评论()    收藏  举报