Copied to clipboard

Flag this post as spam?

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


  • John M. 18 posts 112 karma points
    Aug 01, 2018 @ 09:08
    John M.
    0

    How to set default value for dropdown list

    Hello everybody.I have a dropdown list which has 5 possible values. I would like that it has a default value(not the empty string).Is there a solution for that?I have already tried the solution (How to set default values for properties when creating a new node from document type) which i found in the forum here but it's for textstrings not for dropdownlist! Any help would be really appreciated.

  • Harry Spyrou 212 posts 604 karma points
    Aug 01, 2018 @ 09:59
    Harry Spyrou
    1

    Hello John,

    I was looking at it a while ago and I think it came down to: you need to make a custom editor:

    https://our.umbraco.com/documentation/Tutorials/creating-a-property-editor/

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Aug 01, 2018 @ 13:00
    Paul Seal
    0

    Hi John

    If you are talking about in the razor view, I would do it like this:

    @Html.DropDownListFor(m => m.Category, Model.Categories, "All")
    

    Where you specify "All", that will be the text for the default value.

    If I have missed the point then I'm sorry.

    Paul

  • John M. 18 posts 112 karma points
    Aug 02, 2018 @ 07:19
    John M.
    0

    Good morning and thanks a lot of for the answers both of you!! Paul,maybe i wasn't clear enough!Let me explain you that i am not talking about in the razor view.I want the default value in umbraco backoffice!I have created a dropdown list with 5 options and i would like to achieve that, when user creates a new content based on this document type , the dropdown comes up with the default value!

Please Sign in or register to post replies

Write your reply to:

Draft