Copied to clipboard

Flag this post as spam?

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


  • Darren Wilson 238 posts 646 karma points
    May 27, 2016 @ 16:25
    Darren Wilson
    0

    Display Custom Member Property in Macro

    Hi Folks,

    I'm trying to create a user profile page that displays a users details but not editable. I've managed to create an editable one using the Umbraco EditProfile macro.

    How do I render

     @Html.TextBoxFor(m => pharmacyName, new { @class = "form-control", placeholder = "First Name", data_val_required = "The First Name field is required.", data_val = "true" })
    

    As a string of text - not a text box?

    Sorry I'm a bit of a newbie on this.

    Thanks Darren

  • Paul Seal 524 posts 2890 karma points MVP 7x c-trib
    May 30, 2016 @ 06:21
    Paul Seal
    1

    Hi Darren I think you want @Html.DisplayFor(m => m.FirstName)

  • Darren Wilson 238 posts 646 karma points
    May 31, 2016 @ 10:42
    Darren Wilson
    0

    Cheers Paul, this did the trick!

    Darren

  • Darren Wilson 238 posts 646 karma points
    May 31, 2016 @ 10:44
    Darren Wilson
    100

    Final Code looked like this:

    @if (Members.IsLoggedIn() && profileModel != null){   
    using (Html.BeginUmbracoForm<UmbProfileController>("HandleUpdateProfile", null, new { id = "updateProfileForm" }))
    {
        var member = Members.GetByUsername(profileModel.UserName);
        var pharmacyName = member.GetPropertyValue("pharmacyName");
        var lastName = member.GetPropertyValue("lastName");
    
    
    
        @Html.TextBoxFor(m => profileModel.Name, new { @class = "form-control", placeholder = "Display Name", data_val_required="The Display Name field is required.", data_val="true" })
    
        @Html.TextBoxFor(m => profileModel.Email, new { @class = "form-control", placeholder = "Email", data_val_required="The Email field is required.", data_val="true" })
    
        @Html.DisplayFor(m => pharmacyName)
    
        @Html.TextBoxFor(m => lastName, new { @class = "form-control", placeholder = "Last Name", data_val_required = "The Last Name field is required.", data_val = "true" })    
    
        <button>Save</button>
    }  
    
    }
    
  • 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