Copied to clipboard

Flag this post as spam?

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


  • Nathan 67 posts 146 karma points
    Oct 16, 2014 @ 13:02
    Nathan
    0

    Create CheckBoxList property with prevalues from mvc model

    Hi,

    What I want to do is create a CheckBoxList property so the editor could choose facilities specific for current page (hotel name) in BO, and render content based on what is checked.

    I've created a model:

    public class Facility
    {
        public int Id { get; set; }
        public string Description { get; set; }
        public string IconUrl { get; set; }
    
        public List<Facility> GetFacilities()
        {
            return new List<Facility>() 
            {  
                new Facility() { Id = 4, Description = "Free parking", IconUrl = "" },
                new Facility() { Id = 6, Description = "Spa", IconUrl = "" },
                new Facility() { Id = 7, Description = "Free Wifi", IconUrl = "" },
                new Facility() { Id = 2, Description = "Tennis", IconUrl = "" },
                new Facility() { Id = 9, Description = "Room service", IconUrl = "" },
                new Facility() { Id = 10, Description = "Fitness", IconUrl = "" }
            };
        }
    }
    

    How can I create a CheckBoxList with the values set in GetFacilities() method? Or should I create a new class in AppCode folder with this method? Where is the best place to put this kind of functionality, and how can I achieve this?

    Thanks!

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Oct 16, 2014 @ 18:02
    Dave Woestenborghs
    1

    There are 2 ways to a solution :

    You can create your own property editor that shows a checkbox list.

    Another solution is to use nuPickers, but I haven't tried that myself :

    https://github.com/uComponents/nuPickers

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft