Step 1: Drop a Script Manager in Page and set its EnablePageMethods property to True.
Step 2: Create a function on the server side that needs to be called from Client Side and add the attribute [WebMethod] on top of it.
[System.Web.Services.WebMethod]
public static void SaveInfo(string Id)
{
// Do server side coding……
}
Setp 3: In the Client Side function just call it like.
function makeFavorite(id) {
PageMethods.SaveInfo(id, CallSuccess, CallFailed);
}
// This will be Called on success
function CallSuccess(res, id) {
alert(destCtrl);
}
// This will be Called on failure
function CallFailed(res) {
alert(res.get_message());
}