错误:“未定义PageMethods”

时间:2015-01-22 15:31:30

标签: jquery vb.net pagemethods

嗨,我在使用PageMethods时遇到了麻烦。

我正在查看stackoverflow中的所有信息,但我无法得到问题的答案。

我在vb.net工作。

在代码背后我有:

<WebMethod()> _
Public Shared Function UpdateTime() As String
    Return Now.ToString()
End Function

在java调用中,代码为:

function onSuccess(data) {
    alert();
}

var json = new UsuarioSimple(username, password);

PageMethods.UpdateTime(onSuccess)

webconfig是

<configuration>
  <connectionStrings>
    <add name="DB_PortalRPO" connectionString="XXXXXXXXXXXXXXXXXXXX" providerName="System.Data.SqlClient"/>
  </connectionStrings>

  <system.web>
    <httpHandlers>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>

    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />



    <authentication mode="Forms">
      <forms loginUrl="~/Catalogs/Account/Login.aspx" timeout="2880" />
    </authentication>


    <membership>

      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="DB_PortalRPO"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>

     <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
      </providers>
    </profile>

  </system.web>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

我的Site.Master我将ScriptManager作为:

<form runat="server"> 
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
.
.
.
</form>

登录页面是:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Login.aspx.vb" Inherits="WebApplication3.Login1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Login</title>

    <link rel="Stylesheet"  href="../../Contents/Styles/Login.css" type="text/css" />
    <link rel="Stylesheet"  href="../../Contents/Styles/Site.css" type="text/css" />

    <script type="text/javascript" src="../../Scripts/catalogs/account.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery-1.11.2.min.js"></script>

</head>
<body>
    <form id="form1" runat="server">
        <div class="outer">
            <div class="middle">
                <div class="login">
                    <div class="row">
                        <label>Usuario:</label>
                        <span><input type="text" id="username" /></span>
                    </div>        
                    <div class="row">
                        <label>Password:</label>
                        <span><input type="password" id="password" /></span>
                    </div>

                    <center>
                        <input type="button" id="login" value="Login" />
                    </center>
                </div>
            </div>
        </div>
    </form>
</body>
<script type="text/javascript">
    $(document).ready(function () {
        $("#login").click(function (ev) {
            var username = $("#username").val();
            var password = $("#password").val();

            login($.trim(username), password); // isnide login I call pagemethod which is inside a javascript web page
        });
    });
</script>
</html>

我总是得到这样的信息: 未捕获的ReferenceError:未定义PageMethods

我正在使用Framework 4和jQuery 1.11.2。 我不知道出了什么问题,有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

我发现了错误,也许我今天休息了。当我说我在Site.Master工作的时候,我真的是在Login.aspx工作,而且没有Site.Master

我错了

grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr