The way to do this is as follows:
[WebMethod]
public static string SayHello()
{
return "Hola";
}
On your page, you need to add ScriptManagerand set the EnablePageMethodsvalue of the property trueas follows:
<asp:ScriptManager id="sMgr" runat="server" EnablePageMethods="True" />
, , , - Javascript, SayHello, Javascript:
function InvokeSayHello()
{
alert(PageMethods.SayHello());
}