Try Now
More in this section

Forums / General Discussions / Accessing WebMethod in UserControl via AJAX

Accessing WebMethod in UserControl via AJAX

4 posts, 0 answered
  1. Cem
    Cem avatar
    7 posts
    02 May 2012
    24 Apr 2013
    Link to this post
    I'm trying to do Newsletter Signup List. I want to add new e-mail address via ajax to my module but i cannot access to webmethod under my custom user control. Anyone can help me?

    Ajax code:

    $(function () {
           $('input[type=submit][id$=btnSubscribe]').click(function () {
               var Email = $('#<%=txtEmail.ClientID%>').val().trim();
               if (Email != "") {
                       type: "POST",
                       url: "../../Widgets/ucNewsletterSignup.ascx/AddNewsletter",
                       data: "{'Email': '" + Email + "'}",
                       contentType: "application/json; charset=utf-8",
                       dataType: "json",
                       success: function (msg) {
                           var array = msg.d;
               else {
               return false;

    and my WebMethod under ucNewsletterSignup.ascx User Control:

            public static void AddNewsletter(string Email)
                DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
                Type newslettermoduleType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.NewsletterModule.Newslettermodule");
                DynamicContent newslettermoduleItem = dynamicModuleManager.CreateDataItem(newslettermoduleType);
                newslettermoduleItem.SetValue("Email", Email);
                newslettermoduleItem.SetString("UrlName", "");
                newslettermoduleItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
                newslettermoduleItem.SetValue("PublicationDate", DateTime.Now);
                newslettermoduleItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft");
  2. Steve
    Steve avatar
    3037 posts
    03 Dec 2008
    24 Apr 2013 in reply to Cem
    Link to this post
    What does firebug tell you?...what's happening, can we see a screenshot of the expanded item in the console tab?

    Easy (more elegant) fix is to just leverage the SF WCF framework, it's WAY easier than you think it is
  3. Cem
    Cem avatar
    7 posts
    02 May 2012
    24 Apr 2013 in reply to Steve
    Link to this post
    Hi Steve,

    Console returns me that error
  4. Victor Velev
    Victor Velev avatar
    1345 posts
    06 Jul 2015
    26 Apr 2013
    Link to this post
    Hi Cem,

    The problem is most likely coming from some authorization issues, as the actual call is understood but not allowed. There are several articles which can help you on the topic:



    All the best,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 0 answered