Share via


HtmlHelper<TModel>.ValueFor<TResult> Method

Definition

Returns the formatted value for the specified expression. Specifically, returns the first non-null value found in: the ModelState entry with full name, or the expression evaluated against Model. See NameFor<TResult>(Expression<Func<TModel,TResult>>) for more information about a "full name".

public:
generic <typename TResult>
 virtual System::String ^ ValueFor(System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression, System::String ^ format);
public string ValueFor<TResult> (System.Linq.Expressions.Expression<Func<TModel,TResult>> expression, string format);
abstract member ValueFor : System.Linq.Expressions.Expression<Func<'Model, 'Result>> * string -> string
override this.ValueFor : System.Linq.Expressions.Expression<Func<'Model, 'Result>> * string -> string
Public Function ValueFor(Of TResult) (expression As Expression(Of Func(Of TModel, TResult)), format As String) As String

Type Parameters

TResult

The type of the expression result.

Parameters

expression
Expression<Func<TModel,TResult>>

An expression to be evaluated against the current model.

format
String

The format string (see https://msdn.microsoft.com/en-us/library/txafckwd.aspx) used to format the expression value when returning that value.

Returns

A String containing the formatted value.

Implements

Applies to