2

我正在尝试让我的 asp.net 解决方案与 jquery ajax 一起使用。我正在使用这个例子:

http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/

到目前为止我有这个,但它给了我关于它没有被定义的命名空间错误。Page并且WebMethod没有定义...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PDFLibrary.PDFLibrary
{
    public partial class SaveStructure : Page
    {
        [WebMethod]
        public static string GetDate()
        {
            return DateTime.Now.ToString();
        }
    }
}

有谁知道如何解决这一问题?

谢谢

4

2 回答 2

5

Visual Studio 实际上有一种很好的方法来包含缺失的命名空间。右键单击WebMethod(或任何无法识别的内容),将鼠标悬停在显示的子菜单上Resolve,然后选择using System.Whatever哪个将是您缺少的命名空间。

这是一个很好的功能,它允许您包含命名空间而无需查找它们。

于 2013-06-26T23:52:24.027 回答
0

您需要添加 [System.Web.Script.Services.ScriptService] 和 [WebService(Namespace = "Your namespace(eg http://tempuri.org/ )")]

于 2013-06-27T09:29:22.770 回答