Try our conversational search powered by Generative AI!

Multiple button actions in XForms with MVC


I'm creating multiple XForms forms and having trouble finding a way to go back to re-edit posted data. I've created one page for each XForm where each XForm consists of a question and a next and previous button. If I click the next button it posts to the next page with the next XForm(that page is pointed out from the setting "Page shown after the form has been sent"), and what I can't figure out is how I can handle the previous button to go back to the previous page.

I've found a similar post:

In my view I got(for controlling the posts):

@Html.PropertyFor(x => x.CurrentPage.Form, new { XFormParameters = new EPiServer.XForms.Util.XFormParameters { PostAction = "Posted", SuccessAction = "Success", FailedAction = "Failed" } })

In my Posted method in my controller I got:

XFormActionHelper.AfterSubmitPostedData += OnAfterSubmitPostedData;

It hits the event as it should but "sender" is always null (even though I've specified XFormControl.ControlSetup both in global.asax and in the InitializationModule) so I can't get hold of the XFormControl for looping through the controls as described in the post mentioned above. I guess though that you are supposed to reach the values from the XFormData object(From the InnerXML?), but still, how can I clarify what button the user clicked?

Anyone done something similar?

Jul 30, 2014 16:57

Found a solution for determine what button that was clicked. The problem was that xforms is naming the buttons "http://localhost/sql" and that is not allowed as a parameter in the method as a name, so I changed the name on the button with javascript like:

And then added that to my method like:

        public ActionResult Posted(Valtech.Core.Website.Areas.QuizPage.Models.QuizPage currentPage, XFormPostedData xFormpostedData, string xFormButton)

// Do stuff


Not an elegant solution so please let me know if anyone got a better solution to this. Still confused though why the sender always is null in my events.


Jul 30, 2014 17:53
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.