Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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)

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticLabelFor<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_staticLabelFor<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_staticLabelFor<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_staticLabelFor<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_staticLabelFor<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_staticLabelFor<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.

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.

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<TModelTValue>>

An expression that identifies the property to display.

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.

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.

public static MvcHtmlString LabelFor<TModel, TValue>(
	this HtmlHelper<TModel> html,
	Expression<Func<TModel, TValue>> expression,
	IDictionary<stringobject> htmlAttributes
)

Parameters

html
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression<Func<TModelTValue>>

An expression that identifies the property to display.

htmlAttributes
Type: System.Collections.Generic.IDictionary<StringObject>

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

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<TModelTValue>>

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

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<TModelTValue>>

An expression that identifies the property to display.

labelText
Type: System.String

The label text to display.

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.

public static MvcHtmlString LabelFor<TModel, TValue>(
	this HtmlHelper<TModel> html,
	Expression<Func<TModel, TValue>> expression,
	string labelText,
	IDictionary<stringobject> htmlAttributes
)

Parameters

html
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression<Func<TModelTValue>>

An expression that identifies the property to display.

labelText
Type: System.String

The label text to display.

htmlAttributes
Type: System.Collections.Generic.IDictionary<StringObject>

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

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<TModelTValue>>

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.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
Show:
© 2015 Microsoft