LabelExtensions.LabelFor Method

 

Returns an HTML label element and the property name of the property that is represented by the specified expression.

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

Overload List

Name Description
System_CAPS_pubmethodSystem_CAPS_static 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.

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

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

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

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

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

See Also

LabelExtensions Class
System.Web.Mvc.Html Namespace

Return to top

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.

Syntax

public static MvcHtmlString LabelFor<TModel, TValue>(
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TValue>> expression
)
public:
generic<typename TModel, typename TValue>
[ExtensionAttribute]
static MvcHtmlString^ LabelFor(
    HtmlHelper<TModel>^ html,
    Expression<Func<TModel, TValue>^>^ expression
)
static member LabelFor<'TModel, 'TValue> : 
        html:HtmlHelper<'TModel> *
        expression:Expression<Func<'TModel, 'TValue>> -> MvcHtmlString
<ExtensionAttribute>
Public Shared Function LabelFor(Of TModel, TValue) (
    html As HtmlHelper(Of TModel),
    expression As Expression(Of Func(Of TModel, TValue))
) As MvcHtmlString

Parameters

Return Value

Type: System.Web.Mvc.MvcHtmlString

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

Remarks

A property named Weight might render markup such as the following:

<label for="Weight">
    Weight
</label>

Return to top

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.

Syntax

public static MvcHtmlString LabelFor<TModel, TValue>(
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TValue>> expression,
    IDictionary<string, object> htmlAttributes
)
public:
generic<typename TModel, typename TValue>
[ExtensionAttribute]
static MvcHtmlString^ LabelFor(
    HtmlHelper<TModel>^ html,
    Expression<Func<TModel, TValue>^>^ expression,
    IDictionary<String^, Object^>^ htmlAttributes
)
static member LabelFor<'TModel, 'TValue> : 
        html:HtmlHelper<'TModel> *
        expression:Expression<Func<'TModel, 'TValue>> *
        htmlAttributes:IDictionary<string, Object> -> MvcHtmlString
<ExtensionAttribute>
Public Shared Function LabelFor(Of TModel, TValue) (
    html As HtmlHelper(Of TModel),
    expression As Expression(Of Func(Of TModel, TValue)),
    htmlAttributes As IDictionary(Of String, Object)
) As MvcHtmlString

Parameters

Return Value

Type: System.Web.Mvc.MvcHtmlString

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

Return to top

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.

Syntax

public static MvcHtmlString LabelFor<TModel, TValue>(
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TValue>> expression,
    object htmlAttributes
)
public:
generic<typename TModel, typename TValue>
[ExtensionAttribute]
static MvcHtmlString^ LabelFor(
    HtmlHelper<TModel>^ html,
    Expression<Func<TModel, TValue>^>^ expression,
    Object^ htmlAttributes
)
static member LabelFor<'TModel, 'TValue> : 
        html:HtmlHelper<'TModel> *
        expression:Expression<Func<'TModel, 'TValue>> *
        htmlAttributes:Object -> MvcHtmlString
<ExtensionAttribute>
Public Shared Function LabelFor(Of TModel, TValue) (
    html As HtmlHelper(Of TModel),
    expression As Expression(Of Func(Of TModel, TValue)),
    htmlAttributes As Object
) As MvcHtmlString

Parameters

  • htmlAttributes
    Type: System.Object

    An object that contains the HTML attributes to set for the element.

Return Value

Type: System.Web.Mvc.MvcHtmlString

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

Return to top

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.

Syntax

public static MvcHtmlString LabelFor<TModel, TValue>(
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TValue>> expression,
    string labelText
)
public:
generic<typename TModel, typename TValue>
[ExtensionAttribute]
static MvcHtmlString^ LabelFor(
    HtmlHelper<TModel>^ html,
    Expression<Func<TModel, TValue>^>^ expression,
    String^ labelText
)
static member LabelFor<'TModel, 'TValue> : 
        html:HtmlHelper<'TModel> *
        expression:Expression<Func<'TModel, 'TValue>> *
        labelText:string -> MvcHtmlString
<ExtensionAttribute>
Public Shared Function LabelFor(Of TModel, TValue) (
    html As HtmlHelper(Of TModel),
    expression As Expression(Of Func(Of TModel, TValue)),
    labelText As String
) As MvcHtmlString

Parameters

Return Value

Type: System.Web.Mvc.MvcHtmlString

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

Return to top

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.

Syntax

public static MvcHtmlString LabelFor<TModel, TValue>(
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TValue>> expression,
    string labelText,
    IDictionary<string, object> htmlAttributes
)
public:
generic<typename TModel, typename TValue>
[ExtensionAttribute]
static MvcHtmlString^ LabelFor(
    HtmlHelper<TModel>^ html,
    Expression<Func<TModel, TValue>^>^ expression,
    String^ labelText,
    IDictionary<String^, Object^>^ htmlAttributes
)
static member LabelFor<'TModel, 'TValue> : 
        html:HtmlHelper<'TModel> *
        expression:Expression<Func<'TModel, 'TValue>> *
        labelText:string *
        htmlAttributes:IDictionary<string, Object> -> MvcHtmlString
<ExtensionAttribute>
Public Shared Function LabelFor(Of TModel, TValue) (
    html As HtmlHelper(Of TModel),
    expression As Expression(Of Func(Of TModel, TValue)),
    labelText As String,
    htmlAttributes As IDictionary(Of String, Object)
) As MvcHtmlString

Parameters

Return Value

Type: System.Web.Mvc.MvcHtmlString

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

Return to top

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.

Syntax

public static MvcHtmlString LabelFor<TModel, TValue>(
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TValue>> expression,
    string labelText,
    object htmlAttributes
)
public:
generic<typename TModel, typename TValue>
[ExtensionAttribute]
static MvcHtmlString^ LabelFor(
    HtmlHelper<TModel>^ html,
    Expression<Func<TModel, TValue>^>^ expression,
    String^ labelText,
    Object^ htmlAttributes
)
static member LabelFor<'TModel, 'TValue> : 
        html:HtmlHelper<'TModel> *
        expression:Expression<Func<'TModel, 'TValue>> *
        labelText:string *
        htmlAttributes:Object -> MvcHtmlString
<ExtensionAttribute>
Public Shared Function LabelFor(Of TModel, TValue) (
    html As HtmlHelper(Of TModel),
    expression As Expression(Of Func(Of TModel, TValue)),
    labelText As String,
    htmlAttributes As Object
) As MvcHtmlString

Parameters

  • htmlAttributes
    Type: System.Object

    An object that contains the HTML attributes to set for the element.

Return Value

Type: System.Web.Mvc.MvcHtmlString

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

Return to top