Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm new to the newer versions of Umbraco but quite familiar with old versions. I'm using U10.4.
Essentially, all I'm trying to do is have a set of forms using a custom view model. For this area I don't need any IPublishedContent data, but I'd like to keep the CurrentUmbracoPage() method so I'm using a surface controller.
I am struggling to get it to post to the surfacecontroller using my custom view model. I have tried many solutions.
Can somebody tell me the best approach?
My view model?
public partial class RegistrationViewModel : PublishedContentWrapped//RegistrationPage
public RegistrationViewModel(IPublishedContent content, IPublishedValueFallback publishedValueFallback) : base(content, publishedValueFallback)
As you see I've tried extending both PublishedContentWrapper and the generated content model.
public async Task<IActionResult> Register(RegistrationViewModel page)
I'm using BeginUmbracoForm for routing
using (Html.BeginUmbracoForm<RegistrationPageSurfaceController> ("Register"))
Can somebody tell me how to post to a surface controller with a custom view model?
The error i get is Cannot bind source content type Umbraco.Cms.Web.Common.PublishedModels.RegistrationPage to model type GloucestershireCollege.ViewModels.RegistrationViewModel. Even if i set the constructor to be RegistrationViewModel
Take a look at this article explaining how to achieve that.
I'm not sure if using the @Html.BeginUmbracoForm from a partial is a requirement, but i had some problems with it in the past.
Hope it helps.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted