Share via


HtmlHelper.Label Method (String, Object)

Returns an HTML label that displays the specified text and that has the specified custom attributes.

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

Syntax

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

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

Parameters

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

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 ...attributes...>labelText</label>

See Also

Reference

HtmlHelper Class

Label Overload

System.Web.WebPages.Html Namespace