Share via


IHtmlHelper<TModel>.HiddenFor<TResult> Method

Definition

Returns an <input> element of type "hidden" for the specified expression. Adds a "value" attribute to the element containing 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>
 Microsoft::AspNetCore::Html::IHtmlContent ^ HiddenFor(System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression, System::Object ^ htmlAttributes);
public Microsoft.AspNetCore.Html.IHtmlContent HiddenFor<TResult> (System.Linq.Expressions.Expression<Func<TModel,TResult>> expression, object htmlAttributes);
abstract member HiddenFor : System.Linq.Expressions.Expression<Func<'Model, 'Result>> * obj -> Microsoft.AspNetCore.Html.IHtmlContent
Public Function HiddenFor(Of TResult) (expression As Expression(Of Func(Of TModel, TResult)), htmlAttributes As Object) As IHtmlContent

Type Parameters

TResult

The type of the expression result.

Parameters

expression
Expression<Func<TModel,TResult>>

An expression to be evaluated against the current model.

htmlAttributes
Object

An Object that contains the HTML attributes for the element. Alternatively, an IDictionary<TKey,TValue> instance containing the HTML attributes.

Returns

A new IHtmlContent containing the <input> element.

Remarks

Combines HtmlFieldPrefix and the string representation of the expression to set <input> element's "name" attribute. Sanitizes the string representation of the expression to set element's "id" attribute.

Applies to