asp.net中的页面方法没有响应

asp.net中的页面方法没有响应,asp.net,asmx,pagemethods,Asp.net,Asmx,Pagemethods,我在page方法的帮助下调用了两个服务器端函数,但什么也没发生。 这是我的代码。所以请告诉我我犯了什么错误 我的aspx代码 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

我在page方法的帮助下调用了两个服务器端函数,但什么也没发生。 这是我的代码。所以请告诉我我犯了什么错误

我的aspx代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

</head>
<body>
    <form id="form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <div>
    <a href="#" onclick="javascript:preview();">Test</a>
        <br />
    </div>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

     <br />
     <br />
     <asp:Button ID="btnSetvwState" runat="server" Text="Set Session Val" OnClientClick="SetSessionVal;return false;" />
        <asp:Button ID="btnGetVwState" runat="server" Text="Get Session Val" OnClientClick="GetSessionVal;return false;"/>
   <script language="javascript">
       function preview() {
           alert($get('TextBox1').value);
           PageMethods.GetMessage("Hi", "Joy", onSuccess)
           return false;
       }

       function onSuccess(res) {
           alert(res);
       }

       function GetSessionVal() {
           PageMethods.GetViewState(onSuccess)
           return false;

       }

       function SetSessionVal() {
           alert("pp");
           PageMethods.SetViewState("Hi", "Tridip", onSuccess)
           return false;

       }
    </script>
    </form>
</body>
</html>
请帮我抓住这个错误。谢谢这里(
SetSessionVal
GetSessionVal
):



您看到了什么?什么不起作用,你看到了什么?你试过调试这个吗?你设置断点了吗?怎么搞的?我们不会为您调试代码,但如果您说出您所尝试的,我们会帮助您。请尝试
OnClientClick=“SetSessionVal();return false;”“
记住,return false可能会导致服务器端单击事件处理程序无法启动。无法确定这是否导致了他的问题,是的,缺少()但是当我使用OnClientClick=“SetSessionVal();return false;”时,也没有调用pagemethod。我听不清这个错误。所以请告诉我遗漏了什么。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [System.Web.Services.WebMethod]
        public static string GetMessage(string pr1,string pr2)
        {
            return pr1 + " " + pr2;
        }

        [System.Web.Services.WebMethod(EnableSession=true)] 
        public static void SetViewState()
        {
            HttpContext.Current.Session["data"] = "Hellp";

        }

        [System.Web.Services.WebMethod(EnableSession = true)]
        public static string GetViewState()
        {
           return (String) HttpContext.Current.Session["data"] ;

        }
    }
}
 <asp:Button ID="btnSetvwState" 
             runat="server" Text="Set Session Val" 
             OnClientClick="SetSessionVal();return false;" />
    <asp:Button ID="btnGetVwState" 
                runat="server" Text="Get Session Val" 
                OnClientClick="GetSessionVal();return false;"/>