Thursday, June 21, 2007

PageMethods + Static Methods in AJAX

Javascript can call code behind code, but the code behind method should be a static method and decorated with [WebMethod]

so After you call this webmethod, how do we refresh the page.. (sometimes you need to refresh the page to display the latest values after deleting a record from a grid).

Here are the steps;

1. Write javascript return method in OnClientClick of button
2. Call PageMethods.MethodName
3. Write return true in OnComplete method, this will call OnClick method of button
4. Write refresh, grid rebind methods in the server OnClick Method. This will post back and get the latest record to grid.

No comments: