System.Web.Mvc.HtmlHelperExtension.CheckBoxList C# (CSharp) Méthode

CheckBoxList() public static méthode

public static CheckBoxList ( this helper, IList selectedItems, IEnumerable items, string propertyName ) : string
helper this
selectedItems IList
items IEnumerable
propertyName string
Résultat string
        public static string CheckBoxList(this HtmlHelper helper, IList<string> selectedItems, 
			IEnumerable<string> items, string propertyName)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string item in items)
            {
                bool selected = selectedItems != null && selectedItems.Contains(item);
                // Add the checkbox
                stringBuilder.AppendFormat("<input name=\"{0}\" id=\"{0}\" type=\"checkbox\" value=\"{1}\" {2}>{1}</input><br />",
                    propertyName, item, selected ? "checked" : "");
            }

            return stringBuilder.ToString();
        }
HtmlHelperExtension