Reputation: 79
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 ?
Upvotes: 2
Views: 959
Reputation: 11955
Set EnablePageMethods
to true on the ScriptManager
.
<asp:ScriptManager EnablePageMethods="True" />
Upvotes: 1