Export (0) Print
Expand All

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

Returns a check box input element by using the specified HTML helper, the name of the form field, a value to indicate whether the check box is selected, 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,
	bool isChecked,
	IDictionary<string, Object> htmlAttributes
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper
The HTML helper instance that this method extends.
name
Type: System.String
The name of the form field.
isChecked
Type: System.Boolean
true to select the check box; otherwise, false.
htmlAttributes
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

Show:
© 2014 Microsoft