MultiSelect
Form
This sample shows how to use MultiSelect in a form.
Features
Description
This sample shows how to use MultiSelect in a form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MvcExplorer.Models; using System.Collections.Specialized; namespace MvcExplorer.Controllers { public partial class MultiSelectController : Controller { private IList< string > products = Products.GetProducts(); public ActionResult Form() { ViewBag.Products = products; var model = new CustomerProduct() { Products = new string []{}}; return View(model); } [HttpPost] public ActionResult Form(CustomerProduct model) { ViewBag.Products = products; if (model.Products != null && model.Products.Length > 0) { ViewBag.Message = string .Format(Resources.MultiSelect.Form_Message, string .Join( ", " , model.Products)); } return View(model); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | @using MvcExplorer.Models; @model CustomerProduct @ { String message = ViewBag.Message; List< string > products = ViewBag.Products; } < label > @Html .Raw(Resources.MultiSelect.Form_Text0)</ label > < div > @using (Html.BeginForm()) { < div > @ (Html.C1().MultiSelectFor(model=>model.Products).Bind(products) .Placeholder(Resources.MultiSelect.Form_Placeholder) .HeaderFormat(Resources.MultiSelect.Form_HeaderFormat) ) </ div > < div style = "margin-top: 10px" > < input type = "submit" class = "wj-btn wj-btn-default" value = "@(Resources.MultiSelect.Form_Submit)" /> </ div > } < p > @message</p> </ div > @section Description{ < p > @Html .Raw(Resources.MultiSelect.Form_Text1)</ p > } |