Copied to clipboard

Flag this post as spam?

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


  • Nigel Billingham 11 posts 31 karma points
    Mar 13, 2012 @ 19:18
    Nigel Billingham
    0

    Custom Dropdownlist and Accessing Property in Razor View

    I'm a newbie so apologies if I am asking a daft question.  I'm using Umbraco V5.

    I have a document type and I want to add a dropdownlist property with a set of pre-defined values.  I have created a custom data type, and created the property on the document type in question.  I can create a document of that document type and set the property selecting one of the valid values.  All ok so far.

    When I get to displaying this data in a template, I can't seem to extract this data.  I can do so for all other normal data types like textstring etc.  The template is allocated to the document type.

    This is what my code looks like in my template:

    @{var leftMenu = Umbraco.Field("pageSection");}

    My property is called pageSection, and this is configured to be a custom dropdownlist (which is called "Page Section DropDownList").  What am I doing wrong?  It's bound to be something daft!

  • Nigel Billingham 11 posts 31 karma points
    Mar 13, 2012 @ 22:02
    Nigel Billingham
    0

    Don't worry guys - worked it out.  It's difficult getting answers to Umbraco questions - perhaps this one was too obvious that very few people have posted info on the web about it!

    The correct code is:

    @{string leftMenu = DynamicModel.pageSection;}
  • Nigel Billingham 11 posts 31 karma points
    Mar 20, 2012 @ 20:35
    Nigel Billingham
    0

    Moderator,

    Can you move this to the Umbraco V5 forum please?

    Thanks.

  • Chris Nash 1 post 21 karma points
    Mar 30, 2012 @ 20:40
    Chris Nash
    0

    Thanks, Nigel!  I just had the same problem. 

Please Sign in or register to post replies

Write your reply to:

Draft