Click here to Skip to main content
15,897,518 members
Articles / Web Development / HTML

CheckBoxList(For) - A missing MVC extension (no longer supported)

Rate me:
Please Sign up or sign in to vote.
4.82/5 (44 votes)
4 Feb 2014CPOL6 min read 778.3K   15K   128  
Extends MVC HtmlHelper class so you can create POSTable checkbox list.
/// <summary>
/// Sets settings of an HTML wrapper that is used on a checkbox list
/// </summary>
public class HtmlListInfo {
  public HtmlListInfo(
    HtmlTag htmlTag,
    int columns = 0,
    object htmlAttributes = null,
    TextLayout textLayout = TextLayout.Default,
    TemplateIsUsed templateIsUsed = TemplateIsUsed.No) {

    this.htmlTag = htmlTag;
    Columns = columns;
    this.htmlAttributes = htmlAttributes;
    TextLayout = textLayout;
    TemplateIsUsed = templateIsUsed;
  }

  public HtmlTag htmlTag { get; set; }
	public int Columns { get; set; }
	public object htmlAttributes { get; set; }
  public TextLayout TextLayout { get; set; }

  /// <summary>
  /// Allows to use user-defined html template for checkbox text.
  /// How-To:
  /// If your checkbox list uses class 'City' -
  /// 1) Create 'Views\Shared\DisplayTemplates\City.cshtml' including all directories
  /// 2) Set 'City.cshtml' @model to inherit from class 'City'
  /// 
  /// E.g. 'City.cshtml' may look like:
  /// @model YourNamespace.City
  /// <strong>@Model.Name</strong> - template text
  /// </summary>
  public TemplateIsUsed TemplateIsUsed { get; set; }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Coding is awesome!

Comments and Discussions