how to use jQuery ajax with user controls?

Mehrdad ilchizadeh asked on September 26, 2015 07:18


i want use this code in my webpart:

    type: "POST",
    url: "*TCSection.ascx/InsertTCSection",
    data: "{id:'" + id + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {
        var URL = msg.d;

.cs Code

public static string InsertTCSection(string id)
string result = "deneme";
return result; }

Correct Answer

Maarten van den Hooven answered on September 26, 2015 10:02

Hi Mehrdad,

No you cannot do that because a web part doesn't present a URL. You need to build a webservice.

You can find enough information on the internet (a web part is in ASP.NET a User Control).

Here the same question on Stackoverflow : how to use jQuery ajax with user controls?.

You can also have an look at this article on DevNet where they explain how to this with the smart search web part, it is similar to your solution: Predictive smart search without postbacks

Good luck with coding!!!!

If this answer helped you, please vote for my answer :-)

1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.