Create a web service name
WebMethod.SVC
in the CS file and add the method:
[OperationContract]
[WebInvoke(Method = "POST")]
public void DeleteRec(string ID)
{
DelUser(Convert.ToInt32(ID));
}
On client side, give the path and call the method:
function DeleteMessage() {
var ID = $('[id$="hdnUserId"]').val();
var url = '<%=ResolveUrl("~/WebMethods.svc/DeleteRec")%& gt;';
$.ajax({
type: "POST",
url: url,
contentType: "application/json; charset=utf-8",
data: '{"ID":"' + ID + '"}',
dataType: "json",
success: function (response) {
document.location.href = '<%= ResolveUrl("~/Test1.aspx")%>';
},
error: function (xhr, ajaxOptions, thrownError) {
}
});
}
This was the other way which I got.