November Happy Hour will be moved to Thursday December 5th.

Rendering XForm in MVC

Vote:
 

Which method is the preferred way of rendering a XForm in MVC?

 

Html.PropertyFor(m=>m.XForm, 

, new { XFormParameters = new XFormParameters() { SuccessAction = "Success", FailedAction = "Failed", PostAction = "XFormPost" } })

or

@using Html.BeginXForm(Model.XForm)
Html.RenderXForm(Model.XForm,
new XFormParameters() { SuccessAction = "Success", FailedAction = "Failed", PostAction = "XFormPost" })

Second question:

When using alternative one of the above I don't get the form back after making a post in a XForm, not even reloading the page. All I get is the message you get after making a post. Anyone who knows why? I don't do anything special in the controller actions for success and failure.


#73089
Jul 05, 2013 11:33
Vote:
 

Take a look at http://cjsharp.com/blog/2013/04/11/creating-a-xform-block-in-episerver-7-mvc-with-working-validation-updated/. Although this particularly covers implementation in a block, you could also use it for page integration.

I prefer to use the latter way of rendering, since it gives me a little more control over the output of the form. 

After you implement one of the methods, check the action attribute that's rendered on the form tag and see if you have a MVC action to handle it.

#73111
Jul 05, 2013 15:36
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.