-1

I have solution structure as:

enter image description here

I want to call recommendationProcess function from CTL_RateRecommendationDetails.ascx.cs from

CTL_RateRecommendationDetails.ascx

So i written code as:

$.ajax({
    type: "POST",
    url: "/UserControls/CTL_RateRecommendationDetails.ascx/recommendationProcess",
    contentType: "application/json; charset=utf-8",

    dataType: "json",
    success: function(value) {
        alert(value.d);
    },
    error: function(e) {
        alert("Ajax Error" + JSON.stringify(e));
    }
});

But every time it comes in error block.

I have tried with :

url: "/CTL_RateRecommendationDetails.ascx/recommendationProcess",

And

url: "CTL_RateRecommendationDetails.ascx/recommendationProcess",

But its not calling function.

[System.Web.Services.WebMethod]
    public static void recommendationProcess()
    {

    }
4
  • Any Error in console? Commented Jul 9, 2015 at 7:02
  • When you say it's not calling the function, what error do you get? Commented Jul 9, 2015 at 7:02
  • No error in console but function does not gets called Commented Jul 9, 2015 at 7:04
  • If there is no error and the function isn't called then your event that makes the AJAX request isn't bound properly. If the request works but doesn't find the endpoint then you'd see a 404 in the console. Commented Jul 9, 2015 at 7:06

1 Answer 1

1

You can't call code behinds of user controls from JQuery Ajax

Ref : http://forums.asp.net/t/1423555.aspx

Using jQuery AJAX to call ASP.NET function in control code-behind instead of page code-behind

how-to-access-server-side-method-in-ascx-control-using-jquery-ajax-method

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.