如何在javascript中使用c代码

如何在javascript中使用c代码,javascript,jquery,asp.net,ajax,Javascript,Jquery,Asp.net,Ajax,我是javascript新手。我想用脚本编写asp.net代码。使用下面显示的代码不会产生任何输出。或者我应该使用ajax访问asp.net文件吗 这里是我的示例代码:a.html 如果你想访问C代码,你必须写Webmethod 您必须放置一个脚本管理器 <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"> </asp:ScriptManager> [WebMet

我是javascript新手。我想用脚本编写asp.net代码。使用下面显示的代码不会产生任何输出。或者我应该使用ajax访问asp.net文件吗

这里是我的示例代码:a.html


如果你想访问C代码,你必须写Webmethod

您必须放置一个脚本管理器

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

 [WebMethod]
    public static string Abc()
    {
    }

根据您提出问题的方式和提供的代码,我认为您的第一步是区分asp.net和javascript。
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>

 [WebMethod]
    public static string Abc()
    {
    }
function Test()
{
PageMethods.Abc(onSucess, onError);

        function onSucess(result) {
          alert("Success");
        }
        function onError(result) {
            alert('Cannot process your request at the moment, please try later....');
        }
        return false;
}