Call WebMethod inside UserControl using jQuery Ajax in ASP.Net

Last Reply 20 days ago By dharmendr

Posted 20 days ago

it is possible we call static method in usercontrl (.ascx) like this

but it not work 

$.ajax({
    type: "POST",
    url: "sortinghtmltable.ascx/GetCustomers",
    data: JSON.stringify(obj),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: OnSuccess,
    failure: function (response) {
        alert(response.d);
    },
    error: function (response) {
        alert(response.d);
    }
});

 

Posted 20 days ago

Hi SajidHussa,

You can't call static WebMethod in UserControl.

If you want the use WebService.

Refer below article.

Call (Consume) Web Service (ASMX) using jQuery AJAX in ASP.Net