I've been trying to call a c# function in javascript this way :
function x() {
PageMethods.F1(onSucess, onError);
function onSucess(result) {
alert('Success');
}
function onError(result) {
alert('Something wrong.');
}
}
[WebMethod]
public static boolean F1()
{
return true;
}
<asp:Button ID="Button1" runat="server" OnClientClick="x(); return false" Text="Button" />
But I don't get any result, I mean neither of the alert messages pops up. What exactly is wrong ?
public static string F1() { return "Hello"; }instead, see if that works.