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
Hi All, I am trying to create a registration form using the below code.
This works fine, however, I really want to be able to place my MemberProperties in specific places within my markup, rather than just iterating through them by index.
I have tried to use the code snippets found in this great article: https://24days.in/umbraco-cms/2015/membership-apis-investigation/
But can't seem to get anywhere without a YSOD
Any help would be greatly appreciated,
Tris
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Web.Mvc.Html @using ClientDependency.Core.Mvc @using Umbraco.Web @using Umbraco.Web.Controllers @{ var registerModel = Members.CreateRegistrationModel(); Html.EnableClientValidation(); Html.EnableUnobtrusiveJavaScript(); Html.RequiresJs("/umbraco_client/ui/jquery.js"); Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js"); Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js"); var success = TempData["FormSuccess"] != null; } @if (success) { <p>Registration succeeeded.</p> } else { using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember")) { <fieldset> <legend>Register Member</legend> @Html.ValidationSummary("registerModel", true) @Html.LabelFor(m => registerModel.Name) @Html.TextBoxFor(m => registerModel.Name) @Html.ValidationMessageFor(m => registerModel.Name) <br /> @Html.LabelFor(m => registerModel.Email) @Html.TextBoxFor(m => registerModel.Email) @Html.ValidationMessageFor(m => registerModel.Email) <br /> @Html.LabelFor(m => registerModel.Password) @Html.PasswordFor(m => registerModel.Password) @Html.ValidationMessageFor(m => registerModel.Password) <br /> @if (registerModel.MemberProperties != null) { for (var i = 0; i < registerModel.MemberProperties.Count; i++) { @Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name) @Html.EditorFor(m => registerModel.MemberProperties[i].Value) @Html.HiddenFor(m => registerModel.MemberProperties[i].Alias) <br /> } } @Html.HiddenFor(m => registerModel.MemberTypeAlias) @Html.HiddenFor(m => registerModel.RedirectUrl) @Html.HiddenFor(m => registerModel.UsernameIsEmail) <button>Register</button> </fieldset> } }
Hi Tris,
Can you post the contents of the YSOD? This might give us a clue as to what is going wrong.
Louis
Server Error in '/' Application. Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions. Source Error: Line 62: <div class="cell"> Line 63: <span> Line 64: @Html.LabelFor(m => registerModel.MemberProperties.Find(n => n.Name == "firstName")) Line 65: @Html.TextBoxFor(m => registerModel.MemberProperties.Find(n => n.Name == "firstName")) Line 66: @Html.ValidationMessageFor(m => registerModel.MemberProperties.Find(n => n.Name == "firstName")) Source File: d:\XXXXXX\Earthly-Dev-Repo\Views\Subscribe.cshtml Line: 64 Stack Trace: [InvalidOperationException: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.] System.Web.Mvc.ModelMetadata.FromLambdaExpression(Expression`1 expression, ViewDataDictionary`1 viewData, ModelMetadataProvider metadataProvider) +563 System.Web.Mvc.Html.LabelExtensions.LabelFor(HtmlHelper`1 html, Expression`1 expression, String labelText, IDictionary`2 htmlAttributes, ModelMetadataProvider metadataProvider) +60 System.Web.Mvc.Html.LabelExtensions.LabelFor(HtmlHelper`1 html, Expression`1 expression, String labelText) +60 System.Web.Mvc.Html.LabelExtensions.LabelFor(HtmlHelper`1 html, Expression`1 expression) +55 ASP._Page_Views_Subscribe_cshtml.Execute() in d:\Users\tris\Documents\Earthly-Dev-Repo\Views\Subscribe.cshtml:64 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107 Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +113 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9874329 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3056.0
Hi Louis, for example
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Membership Provider - Registration Form
Hi All, I am trying to create a registration form using the below code.
This works fine, however, I really want to be able to place my MemberProperties in specific places within my markup, rather than just iterating through them by index.
I have tried to use the code snippets found in this great article: https://24days.in/umbraco-cms/2015/membership-apis-investigation/
But can't seem to get anywhere without a YSOD
Any help would be greatly appreciated,
Tris
Hi Tris,
Can you post the contents of the YSOD? This might give us a clue as to what is going wrong.
Louis
Hi Louis, for example
is working on a reply...