LabelExtensions.LabelFor Method
Returns an HTML label element and the property name of the property that is represented by the specified expression.
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
| Name | Description | |
|---|---|---|
![]() ![]() | LabelFor<TModel, TValue>(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>) | Returns an HTML label element and the property name of the property that is represented by the specified expression. |
![]() ![]() | LabelFor<TModel, TValue>(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, IDictionary<String, Object>) | Returns an HTML label element and the property name of the property that is represented by the specified expression. |
![]() ![]() | LabelFor<TModel, TValue>(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, Object) | Returns an HTML label element and the property name of the property that is represented by the specified expression. |
![]() ![]() | LabelFor<TModel, TValue>(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String) | Returns an HTML label element and the property name of the property that is represented by the specified expression using the label text. |
![]() ![]() | LabelFor<TModel, TValue>(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, IDictionary<String, Object>) | Returns an HTML label element and the property name of the property that is represented by the specified expression. |
![]() ![]() | LabelFor<TModel, TValue>(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, Object) | Returns an HTML label element and the property name of the property that is represented by the specified expression. |
LabelExtensions.LabelFor<TModel, TValue> Method (HtmlHelper<TModel>, Expression<Func<TModel, TValue>>)
Returns an HTML label element and the property name of the property that is represented by the specified expression.
public static MvcHtmlString LabelFor<TModel, TValue>( this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression )
Parameters
- html
-
Type:
System.Web.Mvc.HtmlHelper<TModel>
The HTML helper instance that this method extends.
- expression
-
Type:
System.Linq.Expressions.Expression<Func<TModel, TValue>>
An expression that identifies the property to display.
Return Value
Type: System.Web.Mvc.MvcHtmlStringAn HTML label element and the property name of the property that is represented by the expression.
Type Parameters
- TModel
The type of the model.
- TValue
The type of the value.
A property named Weight might render markup such as the following:
<label for="Weight">
Weight
</label>
LabelExtensions.LabelFor<TModel, TValue> Method (HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, IDictionary<String, Object>)
Returns an HTML label element and the property name of the property that is represented by the specified expression.
public static MvcHtmlString LabelFor<TModel, TValue>( this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes )
Parameters
- html
-
Type:
System.Web.Mvc.HtmlHelper<TModel>
The HTML helper instance that this method extends.
- expression
-
Type:
System.Linq.Expressions.Expression<Func<TModel, TValue>>
An expression that identifies the property to display.
- htmlAttributes
-
Type:
System.Collections.Generic.IDictionary<String, Object>
An object that contains the HTML attributes to set for the element.
Return Value
Type: System.Web.Mvc.MvcHtmlStringAn HTML label element and the property name of the property that is represented by the expression.
Type Parameters
- TModel
The type of the model.
- TValue
The type of the value.
LabelExtensions.LabelFor<TModel, TValue> Method (HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, Object)
Returns an HTML label element and the property name of the property that is represented by the specified expression.
public static MvcHtmlString LabelFor<TModel, TValue>( this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object htmlAttributes )
Parameters
- html
-
Type:
System.Web.Mvc.HtmlHelper<TModel>
The HTML helper instance that this method extends.
- expression
-
Type:
System.Linq.Expressions.Expression<Func<TModel, TValue>>
An expression that identifies the property to display.
- htmlAttributes
-
Type:
System.Object
An object that contains the HTML attributes to set for the element.
Return Value
Type: System.Web.Mvc.MvcHtmlStringAn HTML label element and the property name of the property that is represented by the expression.
Type Parameters
- TModel
The type of the model.
- TValue
The value.
LabelExtensions.LabelFor<TModel, TValue> Method (HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String)
Returns an HTML label element and the property name of the property that is represented by the specified expression using the label text.
public static MvcHtmlString LabelFor<TModel, TValue>( this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string labelText )
Parameters
- html
-
Type:
System.Web.Mvc.HtmlHelper<TModel>
The HTML helper instance that this method extends.
- expression
-
Type:
System.Linq.Expressions.Expression<Func<TModel, TValue>>
An expression that identifies the property to display.
- labelText
-
Type:
System.String
The label text to display.
Return Value
Type: System.Web.Mvc.MvcHtmlStringAn HTML label element and the property name of the property that is represented by the expression.
Type Parameters
- TModel
The type of the model.
- TValue
The type of the value.
LabelExtensions.LabelFor<TModel, TValue> Method (HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, IDictionary<String, Object>)
Returns an HTML label element and the property name of the property that is represented by the specified expression.
public static MvcHtmlString LabelFor<TModel, TValue>( this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string labelText, IDictionary<string, object> htmlAttributes )
Parameters
- html
-
Type:
System.Web.Mvc.HtmlHelper<TModel>
The HTML helper instance that this method extends.
- expression
-
Type:
System.Linq.Expressions.Expression<Func<TModel, TValue>>
An expression that identifies the property to display.
- labelText
-
Type:
System.String
The label text to display.
- htmlAttributes
-
Type:
System.Collections.Generic.IDictionary<String, Object>
An object that contains the HTML attributes to set for the element.
Return Value
Type: System.Web.Mvc.MvcHtmlStringAn HTML label element and the property name of the property that is represented by the expression.
Type Parameters
- TModel
The type of the model.
- TValue
The type of the value.
LabelExtensions.LabelFor<TModel, TValue> Method (HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, Object)
Returns an HTML label element and the property name of the property that is represented by the specified expression.
public static MvcHtmlString LabelFor<TModel, TValue>( this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string labelText, object htmlAttributes )
Parameters
- html
-
Type:
System.Web.Mvc.HtmlHelper<TModel>
The HTML helper instance that this method extends.
- expression
-
Type:
System.Linq.Expressions.Expression<Func<TModel, TValue>>
An expression that identifies the property to display.
- labelText
-
Type:
System.String
The label text.
- htmlAttributes
-
Type:
System.Object
An object that contains the HTML attributes to set for the element.
Return Value
Type: System.Web.Mvc.MvcHtmlStringAn HTML label element and the property name of the property that is represented by the expression.
Type Parameters
- TModel
The type of the model.
- TValue
The Value.

