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());
}
4 comments:
ooh..That great.I never though this is so easy :)
It saved me hours to resolve an error... Thanks for your quick and easy posts...
not working can u give me example code if possible.
@AfterWeb:
The function that you are calling from clent side should have to be static only then you can call it.
Regards,
U
Post a Comment