Hi Vanmathy, maybe this post can be helpful https://world.episerver.com/blogs/team-oshyn/dates/2016/3/posting-forms-with-episerver-mvc/
Hello Vanmathy
First of all welcome to the Episerver comminuty!
The Alloy demo site solution has a page that allows users to update their profile using a form on page which you could adapt. Code:
Controller: https://github.com/episerver/AlloyDemoKit/blob/master/src/AlloyDemoKit/Controllers/ProfilePageController.cs
David
I'm a beginner in episerver. I created a custom form which on submit, has to create a page(same as formpage type) dynamically and pass the property values to that page.
This page is saved with ready to publish status, so that epi admin can publish it from epi backend.
Please, suggest me how to associate the form property values to the newly created page.
VIEW:
@model PageViewModel
@{ Layout = "~/Views/Shared/Layouts/_Root.cshtml"; }
@using (Html.BeginForm("Submit", "BlogPage", FormMethod.Post, Model))
{
@Html.LabelFor(m => m.CurrentPage.ListingTitle)
@Html.TextBoxFor(m => m.CurrentPage.ListingTitle)
@Html.LabelFor(m => m.CurrentPage.Brief)
@Html.TextAreaFor(m => m.CurrentPage.Brief)
@Html.LabelFor(m => m.CurrentPage.Title)
@Html.TextBoxFor(m => m.CurrentPage.Title)
@Html.LabelFor(m => m.CurrentPage.Description)
@Html.TextAreaFor(m => m.CurrentPage.Description)
@Html.LabelFor(m => m.CurrentPage.AuthorName)
@Html.TextBoxFor(m => m.CurrentPage.AuthorName)
CONTROLLER:
public ActionResult Index(BlogPage currentPage)
{
var model = PageViewModel.Create(currentPage);
return View(model);
}
[HttpPost]();();(parent);
public ActionResult Submit(BlogPage currentPage)
{
PageReference parent = PageReference.StartPage;
IContentRepository contentRepository = ServiceLocator.Current.GetInstance
IContentTypeRepository contentTypeRepository = ServiceLocator.Current.GetInstance
BlogPage blog = contentRepository.GetDefault
blog.Name ="currentPage.Title";
blog.AuthorName = "currentPage.AuthorName";
blog.Brief = currentPage.Brief;
contentRepository.Save(blog, EPiServer.DataAccess.SaveAction.CheckIn);
return Content("ThankYou");
}
In the httppost, current page properties are null!.Please do guide me !