来自JavaScript的WebMethod调用失败。

时间:2011-06-08 15:03:23

标签: c# javascript .net web-services webmethod

我有以下课程

namespace UI
{
    /// <summary>
    /// Summary description for Registration1
    /// </summary>
    [WebService(Namespace = "UI")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
    public class Registration1 : System.Web.Services.WebService
    {
        [WebMethod]
        public static string RegisterUser(string sFirstName)
        {
            return "hello";
        }
    }

在客户端我添加了我的JavaScript,

UI.Registration.RegisterUser(txtFirstName.get_value(),Register_success, onFailed);

在Script Manger中

<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    <Services>
        <asp:ServiceReference Path="~/Registration.asmx" />
    </Services>
</telerik:RadScriptManager>

但是,当我运行它时,它没有看到UI命名空间,并且我收到了JavaScript运行时错误。

1 个答案:

答案 0 :(得分:2)

您的类名为Registration1,但您在名为Registration的类上调用方法。