MobyDog
07/28/2023, 1:49 PMMobyDog
07/28/2023, 1:51 PMhuwred
07/28/2023, 1:53 PMMobyDog
07/28/2023, 2:02 PMMobyDog
07/28/2023, 2:15 PMInvalidOperationException: Could not find a Surface controller route in the RouteTable for controller name GatedAccessSurface
Umbraco.Cms.Web.Website.Routing.UmbracoRouteValueTransformer.HandlePostedValues(PostedDataProxyInfo postedInfo, HttpContext httpContext)
I don't have any surface controller set up at the moment. I just have \App_Code\Components\GatedAccess\GatedAccessViewComponent.csMobyDog
07/28/2023, 2:16 PMnamespace Website.App_Code.Components.GatedAccess
{
public class GatedAccessViewComponent : ViewComponent
{
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IUmbracoContextFactory _umbracoContextFactory;
public GatedAccessViewComponent(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoContextFactory umbracoContextFactory)
{
_umbracoContextAccessor = umbracoContextAccessor;
_umbracoContextFactory = umbracoContextFactory;
}
public IViewComponentResult Invoke()
{
GatedAccessItem model = new GatedAccessItem();
var content = _umbracoContextAccessor.GetRequiredUmbracoContext().PublishedRequest.PublishedContent;
model.pageUrl = content.Url();
model.fileName = String.Empty;
etc etc
model.gac_optin = false;
return View(model);
}
}
}
MobyDog
07/28/2023, 2:17 PM@using System.Web;
@using Website.App_Code.Controllers;
@using Website.App_Code.Models;
@model GatedAccessItem
<div class="gated-access-block">
@Html.TextBoxFor(m => m.gac_email, new { autocapitalize = "off", @class = "form-control", placeholder = Model.emailLabelAlias })
@Html.TextBoxFor(m => m.gac_name, new { @class = "form-control", placeholder = "name" })
@Html.TextBoxFor(m => m.gac_companyName, new { @class = "form-control", placeholder = "company" })
</div>
MobyDog
07/28/2023, 2:18 PMasync void VideoGated()
{
if (Model.Value<bool>("gated")) // && !GatedAccessLogic.UserIsRegistered())
{
@await Component.InvokeAsync("GatedAccess")
}
}
MobyDog
07/28/2023, 2:18 PMhuwred
07/28/2023, 2:20 PMMobyDog
07/28/2023, 2:23 PMhuwred
07/28/2023, 2:32 PMMobyDog
07/28/2023, 2:40 PMMobyDog
07/28/2023, 2:41 PMhuwred
07/28/2023, 2:41 PMMobyDog
07/28/2023, 2:58 PMMobyDog
07/28/2023, 8:54 PMCodeSharePaul
07/28/2023, 9:33 PMMike Chambers
07/31/2023, 9:13 AMbeginForm
makes it easier to avoid typos..
and if you use umb tag helpers (https://our.umbraco.com/packages/website-utilities/our-umbraco-taghelpers/) makes the view nice for the fronends who are no doubt used to vue/react now..
<form method="post" class="form" our-controller="@(nameof(ContactFormSurfaceController).Replace("Controller", ""))" our-action="@(nameof(ContactFormSurfaceController.SubmitContactForm))" id="frmContact">
...
</form>
you could evn go the extra mile and add the controller/action names to the viewComponent Model to make it super clean...
<form method="post" class="form" our-controller="@(Model.FormController)" our-action="@(Model.FormAction)" id="frmContact">
🙂 ( though might not be a Umbraco Ajax Form still!)MobyDog
07/31/2023, 10:22 AM