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 would like to get the form data from a async post request. How should the surfacecontroller looks like (with parameters)?
@inherits UmbracoViewPage<Product> @using ContentModels = Umbraco.Web.PublishedModels; @{ Layout = "master.cshtml"; } <!-- for the section we want to show the shop header --> @Html.Partial("~/Views/Partials/SectionHeader.cshtml", Model.Parent) <section class="section"> <div class="container"> <div class="row"> <div class="col-md-6"> <div class="product-image-container"> <img class="product-image" src="@Model.Photos.Url()" alt="@Model.ProductName image" /> </div> </div> <div class="col-md-6"> <h1>@Model.ProductName</h1> <div class="product-price">@Model.Parent.GetProperty("DefaultCurrency").Value() @Model.Price.ToString("F")</div> <div class="product-teaser">@Model.Description</div> <div class="product-button"> @using (Ajax.BeginForm(actionName: "AddProductForm", controllerName: "NetShopBasketSurface", routeValues: null, ajaxOptions: new AjaxOptions() { UpdateTargetId = "form-result", HttpMethod = "post", InsertionMode = InsertionMode.Replace, OnSuccess = "addProductForm.showResult", OnFailure = "addProductForm.showResult" }, htmlAttributes: new { id = "pform" })) { <div> @Html.HiddenFor(m => m.ProductName) <button class="product-submit button button--border--solid" type="submit" id="addProductButton">Tilføj til kurv</button> </div> @*<button class="button button--border--solid">Tilføj til indkøbskurv</button>*@ } </div> <div class="product-advantages"> @if (Model.Features != null) { foreach (var feature in Model.Features) { <div class="product-advantage"> <h4>@feature.GetProperty("featureName").Value()</h4> <h5>@feature.GetProperty("featureDetails").Value()</h5> </div>} } </div> </div> </div> </div> </section> <section class="section section--sand"> <div class="container"> <!-- todo: Check if grid is empty via a property value converter --> @Html.GetGridHtml(Model, "bodyText", "bootstrap3-fluid") </div> </section> <div id="form-result"></div>
Hi Klaus
SurfaceController is just a controller with Umbraco-specific routing.
Just inherit a controller class from SurfaceController base class, and you have a surface controller.
An example:
public class MemberController : SurfaceController { [HttpPost] [ValidateAntiForgeryToken] public ActionResult Login(LoginViewModel model) { return CurrentUmbracoPage(); } }
Read more here - https://our.umbraco.com/documentation/reference/routing/surface-controllers
All surface controllers get routed to:
/umbraco/surface/{controllername}/{action}/{id}
Thanks,
Alex Skrypnyk
Hi Alex Thanks for your response.
As you can see in my View it is of type UmbracoViewPage < Product >. Can I pass a < Product > to the surface controller? I do seem to get a 500 internal server error when i do so. Dont know why.
Thanks //Klaus
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
What Model is being passed to the Surface controller?
I would like to get the form data from a async post request. How should the surfacecontroller looks like (with parameters)?
Hi Klaus
SurfaceController is just a controller with Umbraco-specific routing.
Just inherit a controller class from SurfaceController base class, and you have a surface controller.
An example:
Read more here - https://our.umbraco.com/documentation/reference/routing/surface-controllers
All surface controllers get routed to:
Thanks,
Alex Skrypnyk
Hi Alex Thanks for your response.
As you can see in my View it is of type UmbracoViewPage < Product >. Can I pass a < Product > to the surface controller? I do seem to get a 500 internal server error when i do so. Dont know why.
Thanks //Klaus
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.