Copied to clipboard

Flag this post as spam?

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


  • Onno Sloof 23 posts 43 karma points
    Apr 09, 2014 @ 16:27
    Onno Sloof
    0

    How to determine member type property is mandatory?

    Hi,

    I'm using Umbraco 7.1.1.
    I've created a Partial View with 'Register member' snippet.

    How do I check if a MemberProperty is mandatory?
    I know Name, Email and Password are by default, but with extra custom properties it's optional.

    Thanks

    Onno

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 09, 2014 @ 16:35
    Jan Skovgaard
    0

    Hi Onno

    What is your scenario? What are you trying to build? I'm not quite sure I understand your question.

    Are you building a member profile page or are you building a login system? Or are you updating the member properties in some code like Razor or C#?

    /Jan

  • Onno Sloof 23 posts 43 karma points
    Apr 10, 2014 @ 08:26
    Onno Sloof
    0

    Hi Jan,

    I'm trying to build a login system in Razor.
    I created some Partial Views with snippets 'Login', 'Login status', 'Register member' and 'Edit profile'.

    In the 'Register member' cshtml file their is default code like

    @Html.LabelFor(m => registerModel.Email)
    @Html.TextBoxFor(m => registerModel.Email)
    @Html.ValidationMessageFor(m => registerModel.Email)

    But because i'm creating this for a Dutch system I need my own layout.
    ValidationMessageFor in code above gives only English message.

    And in the code below, I want to be able te determine if a memberproperty is Mandatory so I can place an '*' behind the label.

    @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 />
       }
    }

    Thanks,

    Onno

     

  • Thomas Egebrand Gram 63 posts 138 karma points
    May 04, 2014 @ 19:31
    Thomas Egebrand Gram
    0

    Hello Onno,

    I ran into the same problem with the labels, you can solve the problem by doing something like this:

    @Html.LabelFor(m => registerModel.Name, "Your Label")

    Or if you want to use a dictionary value from Umbraco:

    @Html.LabelFor(m => registerModel.Name, Umbraco.GetDictionaryValue("Name"))

    Unfortunately i haven't quite figured out how to deal with the member properties either just yet.

    // Thomas Gram

  • 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.

Please Sign in or register to post replies