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)
Syntax
'Declaration
Public Function Label ( _
labelText As String, _
labelFor As String, _
attributes As IDictionary(Of String, Object) _
) As IHtmlString
'Usage
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
)
public:
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
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.Collections.Generic.IDictionary<String, Object>
The names and values of custom attributes for the 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" ...attributes...>labelText</label>