views:

26

answers:

1

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.

+1  A: 

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)
{      
}
brendan