HtmlHelper.Label Method (String, String, Object)

Returns an HTML label that displays the specified text, and that has the specified for attribute and custom attributes defined by an attribute object.

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


Public Function Label ( _
    labelText As String, _
    labelFor As String, _
    attributes As Object _
) As IHtmlString
Dim instance As HtmlHelper 
Dim labelText As String 
Dim labelFor As String 
Dim attributes As Object 
Dim returnValue As IHtmlString 

returnValue = instance.Label(labelText, _
    labelFor, attributes)
public IHtmlString Label(
    string labelText,
    string labelFor,
    Object attributes
IHtmlString^ Label(
    String^ labelText, 
    String^ labelFor, 
    Object^ attributes
member Label : 
        labelText:string * 
        labelFor:string * 
        attributes:Object -> IHtmlString
public function Label(
    labelText : String, 
    labelFor : String, 
    attributes : Object
) : IHtmlString


  • labelFor
    Type: System.String
    The value to assign to the for attribute of the HTML control element.
  • attributes
    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 label.


Exception Condition

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


The returned markup consists of an HTML label element in the following form:

<label for="labelFor" ...attributes...>labelText</label>

See Also


HtmlHelper Class

Label Overload

System.Web.WebPages.Html Namespace