Share via


HtmlHelper.CheckBox Method (String, Boolean, Object)

Returns an HTML check box control that has the specified name, default checked status, and custom attributes defined by an attribute object.

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

Syntax

'Declaration
Public Function CheckBox ( _
    name As String, _
    isChecked As Boolean, _
    htmlAttributes As Object _
) As IHtmlString
'Usage
Dim instance As HtmlHelper 
Dim name As String 
Dim isChecked As Boolean 
Dim htmlAttributes As Object 
Dim returnValue As IHtmlString 

returnValue = instance.CheckBox(name, _
    isChecked, htmlAttributes)
public IHtmlString CheckBox(
    string name,
    bool isChecked,
    Object htmlAttributes
)
public:
IHtmlString^ CheckBox(
    String^ name, 
    bool isChecked, 
    Object^ htmlAttributes
)
member CheckBox : 
        name:string * 
        isChecked:bool * 
        htmlAttributes:Object -> IHtmlString
public function CheckBox(
    name : String, 
    isChecked : boolean, 
    htmlAttributes : Object
) : IHtmlString

Parameters

  • name
    Type: System.String
    The value to assign to the name attribute of the HTML control element.
  • isChecked
    Type: System.Boolean
    true to indicate that the checked attribute is set to checked; otherwise, false.
  • htmlAttributes
    Type: System.Object
    An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.

Return Value

Type: System.Web.IHtmlString
The HTML markup that represents the check box control.

Exceptions

Exception Condition
ArgumentException

name is null reference (Nothing in Visual Basic) or empty.

Remarks

The returned markup consists of an HTML input element in one of the following forms:

<input type="checkbox" name="name" checked="checked" ...htmlAttributes... />

isChecked is true.

<input type="checkbox" name="name" ...htmlAttributes... />

isChecked is false.

See Also

Reference

HtmlHelper Class

CheckBox Overload

System.Web.WebPages.Html Namespace