HtmlHelper.Label Method (String, String, IDictionary<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 dictionary.

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 IDictionary(Of String, Object) _
) As IHtmlString
Dim instance As HtmlHelper 
Dim labelText As String 
Dim labelFor As String 
Dim attributes As IDictionary(Of String, Object)
Dim returnValue As IHtmlString 

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


  • labelFor
    Type: System.String
    The value to assign to the for attribute of the HTML control element.

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