Copied to clipboard

Flag this post as spam?

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


  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Mar 07, 2018 @ 12:37
    Hendy Racher
    0

    AjaxHelper UmbracoBeginForm Extension Methods

    Hi,

    We have the BeginUmbracoForm extension method on the HtmlHelper, are there any plans for an equivalent extension method for the AjaxHelper ? (or perhaps there is already one and I can't find it ?)

    At the moment to be able to get the current page (and language) in the controller from an AJAX call we store values in hidden form fields, but it would be nice if this was handled automatically by Umbraco, like it does with the BeginUmbracoForm method.

    Thanks, Hendy

  • Garðar Þorsteinsson 119 posts 565 karma points
    Mar 07, 2018 @ 12:46
    Garðar Þorsteinsson
    0

    Hi Hendy,

    When using this with SurfaceController the Context is sent with the form data so the culture should be correct in the controller.

    @using (Html.BeginUmbracoForm("Action", "Controller"))
    {
    
    }
    
  • Michael 125 posts 409 karma points
    Mar 07, 2018 @ 12:55
    Michael
    0

    Hey Hendy,

    I'm using this code for AJAX forms:

    @using(Ajax.BeginForm("ActionName", "SurfaceController", null, new AjaxOptions
        {
            HttpMethod = "POST",
            InsertionMode = InsertionMode.Replace,
            UpdateTargetId = "replace-id"
        }, new { @class = "css-class", id = "form-id" }))
    {
    }
    
  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Mar 07, 2018 @ 13:03
    Hendy Racher
    0

    Thanks for your replies.

    @Garðar, yes that works for a regular form, and context is restored - but I'd like to be able to do similar with an Ajax.BeginForm() (or an Ajax.BeginUmbracoForm()) where AjaxOptions can be passed though and handled.

    @Michael, that's what I'm doing at the moment, but the controller doesn't restore context (without manually injecting hidden fields) - perhaps it should and I'm just doing something wrong ?

    Thanks, Hendy

  • Garðar Þorsteinsson 119 posts 565 karma points
    Mar 07, 2018 @ 13:39
    Garðar Þorsteinsson
    1

    I understand.

    We have never used the Ajax.BeginForm.

    Usually we would always create our own javascript binding on the form with BeginUmbracoForm.

    We have no problem using ajax that way with the forms.

Please Sign in or register to post replies

Write your reply to:

Draft