HtmlHelper.Label Method (String, String)

Returns an HTML label that displays the specified text and that has the specified for attribute.

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

Syntax

'Declaration
Public Function Label ( _
    labelText As String, _
    labelFor As String _
) As IHtmlString
'Usage
Dim instance As HtmlHelper 
Dim labelText As String 
Dim labelFor As String 
Dim returnValue As IHtmlString 

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

Parameters

  • 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.

Exceptions

Exception Condition
ArgumentException

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

Remarks

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

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

The labelFor parameter specifies the id attribute of the HTML control that is associated with the label.

See Also

Reference

HtmlHelper Class

Label Overload

System.Web.WebPages.Html Namespace