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

推荐订阅源

有赞技术团队
有赞技术团队
美团技术团队
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
V
V2EX
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)
量子位
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
月光博客
月光博客
L
LangChain Blog

博客园 - 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)  评论()    收藏  举报