Reputation: 3173
Hello I call static PageMethod from JS. PageMethod send some information to emails. When I call it, page reloads. How should i prevent reloading page during PageMethod and do it at ajax style?
Thanks.
Upvotes: 0
Views: 1228
Reputation: 29986
To prevent the page from posting back you probably want to add return false;
to the end of your javascript call.
Like this:
<asp:Button ID="Button1" runat="server" Text="Call Page Methods"
OnClientClick="return fun()"/>
Then in JS:
function fun()
{
PageMethods.MyPageMethod(onSucceed, onError);
return false;
}
function onSucceed(result)
{
alert(result);
}
function onError(result)
{
}
Upvotes: 1