Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • marina.b 13 posts 103 karma points
    May 26, 2021 @ 13:18
    marina.b
    0

    How can I add a CheckBox in the Member Registration Form ?

    Hi All, I have created a Members‘ Register Page, but I need to add a CheckBoxFro related to a CustomProperty to store the acceptance of the Privacy Policy. I’ ve seen that the code renders only TextString. I tried (as suggested in the notes) to create a custom editor (MyEditor.cshtml) to define the CheckBoxFor, but I always got the following error.

    Compiler Error Message: CS1003: Syntax error, ',' expected

    Source Error:

    Line 34: Line 35: Line 36: public class PageViewsSharedEditorTemplatesMyEditorcshtml : System.Web.Mvc.WebViewPage

    Source File: C:\Users\xxxx\AppData\Local\Temp\Temporary ASP.NET Files\root\c74c3b26\221b46d3\AppWebmyeditor.cshtml.5e279d63.t7h3tlc2.0.cs Line: 36

    MyEditor.cshtml is the following:

    @model Member.CreateRegistrationModel()
    <div>
    
        @Html.CheckBoxFor(m=> m.privacy, new  {true})
    
    
    </div>
    

    Where am I wrong?

  • marina.b 13 posts 103 karma points
    May 26, 2021 @ 17:34
    marina.b
    100

    Found out. There were several mistakes. Thanks to Jakob and Anthony of Umbr.coach, I succeeded in solving.

    This is the new MyEditor.cshtml that works.

    @model Umbraco.Web.PublishedModels.Member
    
    @Html.CheckBoxFor(m=> m.Privacy, new  { @checked= false})
    

    Hope it could be useful.

Please Sign in or register to post replies

Write your reply to:

Draft