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 | using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Linq; using MvcExplorer.Models; 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(Localization.MultiSelectRes.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 27 28 | @model CustomerProduct @ { String message = ViewBag.Message; List< string > products = ViewBag.Products; } < label > @Html .Raw(MultiSelectRes.Form_Text1)</ label > < div > < form asp-action = "Form" > < div > < c1-multi-select for = "@Model.Products" placeholder = "@MultiSelectRes.Form_Placeholder" header-format = "@MultiSelectRes.Form_HeaderFormat" > < c1-items-source source-collection = "products" /> </ c1-multi-select > </ div > < div style = "margin-top: 10px" > < input type = "submit" class = "wj-btn wj-btn-default" value = "@(MultiSelectRes.Form_Submit)" /> </ div > </ form > < p > @message</p> </ div > @section Description{ < p > @Html .Raw(MultiSelectRes.Form_Text0)</ p > } |