Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • David McDonnell 53 posts 251 karma points
    Apr 06, 2017 @ 14:50
    David McDonnell

    @Ajax.ActionLink to return Partial View and update inner content div on page

    Hi all, I am attempting to Render a Partial View in a div on the same page on the click event of a hyperlink via Ajax.

    But everytime the href of the link is blank and instead loads the index action on the page controller. I have done this successfully in a standard MVC application but with Umbraco it refuses to work.

    In My Page View I have:

    @Ajax.ActionLink("Click Here",
                   new AjaxOptions
                       HttpMethod = "GET",
                       InsertionMode = InsertionMode.Replace,
                       UpdateTargetId = "updateView"
    <div id="updateView"></div>

    In My Controller:

        public class TestPageController : RenderMvcController
           public ActionResult Index()
               UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current);
               var content = helper.TypedContent(UmbracoContext.Current.PageId);
               var model = new TestModel(content);
               return View(model);
           public PartialViewResult TestPartialAction()
               return PartialView("_testPartial");

    My Partial just has plain HTML at the moment

    But the resulting markup for the anchor is:

    <a data-ajax="true" data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#updateView" href="">Click Here</a>

    Any help would be greatly appreciated

  • David McDonnell 53 posts 251 karma points
    Apr 07, 2017 @ 09:57
    David McDonnell

    Hi all nevermind it was a simple mistake of not calling the Register Routes in my Global.cs file.

  • David Amri 214 posts 740 karma points
    Mar 02, 2020 @ 12:19
    David Amri

    Hi, I have the same issue with an empty href attribute. What did you do to solve this issue?

Please Sign in or register to post replies

Write your reply to: