Call WebMethod inside UserControl using jQuery Ajax in ASP.Net

Last Reply 11 months ago By dharmendr

Posted 11 months 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 11 months 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