C# 是否可以在SharePoint 2007中使用jquery调用页面方法?

C# 是否可以在SharePoint 2007中使用jquery调用页面方法?,c#,jquery,ajax,sharepoint-2007,moss,C#,Jquery,Ajax,Sharepoint 2007,Moss,我们有一个自定义的aspx页面,其中代码隐藏类部署在GAC的DLL中。我试图使用jquery调用codebehind中的一个方法来获取文本框的自动完成行为。该方法具有[WebMethod]属性。该代码在测试asp.net应用程序中运行良好,但部署到SharePoint服务器时,我收到一个“httpexception-目录C:\Inetpub\wwwroot…\catalogs\masterpage不存在。无法开始监视文件更改”错误。页面中没有scriptmanager标记 在您的代码隐藏中,将他

我们有一个自定义的aspx页面,其中代码隐藏类部署在GAC的DLL中。我试图使用jquery调用codebehind中的一个方法来获取文本框的自动完成行为。该方法具有[WebMethod]属性。该代码在测试asp.net应用程序中运行良好,但部署到SharePoint服务器时,我收到一个“httpexception-目录C:\Inetpub\wwwroot…\catalogs\masterpage不存在。无法开始监视文件更改”错误。页面中没有scriptmanager标记

在您的代码隐藏中,将他的属性添加到您的函数[WebMethod]之上,然后您应该能够通过Jquery调用它

有关更多信息,请查看此处

将此添加到asp.net表单标记下

<asp:ScriptManager ID="scriptManager" EnablePageMethods="true" runat="server"/>
并将其添加到您的aspx文件中

    <script>
        function GetHi() {

            PageMethods.SayHi(onComplete);
        }

        function onComplete(result) {
            alert(result);
        }

        GetHi();
</script>

函数GetHi(){
PageMethods.SayHi(onComplete);
}
函数完成(结果){
警报(结果);
}
GetHi();

并尽量不要将代码隐藏在yr GAC中

“该方法具有[WebMethod]属性。”来自hia问题。
    <script>
        function GetHi() {

            PageMethods.SayHi(onComplete);
        }

        function onComplete(result) {
            alert(result);
        }

        GetHi();
</script>