Chosen jQuery plugin with MVC 5

Chosen is a jQuery plugin that makes long, unwieldy select boxes much more user-friendly.


 public class CustomerCategoryOption
        public int ID { get; set; }
        public string CategoryName { get; set; }


    public ActionResult Index()
            List customerCategoryOption = new List() { 
              new CustomerCategoryOption{ID=1, CategoryName = "PLATINUM"},
              new CustomerCategoryOption{ID=2, CategoryName = "SILVER"},
              new CustomerCategoryOption{ID=3, CategoryName = "GOLD"},
              new CustomerCategoryOption{ID=4, CategoryName = "ABC"},
              new CustomerCategoryOption{ID=5, CategoryName = "ABD"},
              new CustomerCategoryOption{ID=6, CategoryName = "ABM"},

            ViewBag.CustomerCategory = new SelectList(customerCategoryOption, "ID", "CategoryName");

            return View();


  ViewBag.Title = "Index";


@Html.DropDownList(“ID”, (IEnumerable)ViewBag.CustomerCategory, new { @class = “chosen” })



Ref Link:

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: