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)
Syntax
'Declaration
Public Function Label ( _
labelText As String, _
labelFor As String, _
attributes As Object _
) As IHtmlString
'Usage
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
)
public:
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
Parameters
- labelText
Type: System.String
The text to display.
- 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.
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" ...attributes...>labelText</label>