PageMethods In ASP.NET AJAX
We all come across to such situation where you need to call server side code from JavaScript, not using jQuery AJAX though, without allowing form to post back to it. Further posting was required to capture data and save it into the database as well. Page Methods is a mechanism introduced in ASP.Net 2.0 where the server code cab be bound to Asp.Net pages. It is an easy way to communicate asynchronously with the server using Asp.Net Ajax technologies. It’s an alternate way to call the page which is reliable and low risk. In a nutshell, it is used to expose the web methods to the client script. Here are few easy steps we will be doing to get this done: 1. Create a JavaScript method. I will name it “ CallServereMethod ”. Here is the code: function CallServereMethod() { var OrderID = document.getElementById(“txtOrderID.Text”).Text; PageMethods.PlaceOrder(OrderID,onSucceed, onError); t...