MSDN Library

InputExtensions.CheckBox Method (HtmlHelper, String, IDictionary<String, Object>)

Returns a check box input element by using the specified HTML helper, the name of the form field, and the HTML attributes.

Namespace:  System.Web.Mvc.Html
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

public static string CheckBox(
	this HtmlHelper htmlHelper,
	string name,
	IDictionary<string, Object> htmlAttributes


Type: System.Web.Mvc.HtmlHelper
The HTML helper instance that this method extends.
Type: System.String
The name of the form field.
Type: System.Collections.Generic.IDictionary<String, Object>
The HTML attributes for the element.

Return Value

Type: System.String
An input element that has its type attribute set to "checkbox".

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type HtmlHelper. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Check boxes are used when you want to let the user select one or more options from a set of alternatives. If only one option should be selected at a time, you should use radio buttons instead.

Community Additions

© 2015 Microsoft