Share via


HtmlHelperInputExtensions.RadioButtonFor<TModel,TResult> Method

Definition

Returns an <input> element of type "radio" for the specified expression. Adds a "value" attribute to the element containing the value parameter. Adds a "checked" attribute to the element if value matches 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 TModel, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ RadioButtonFor(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper<TModel> ^ htmlHelper, System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression, System::Object ^ value);
public static Microsoft.AspNetCore.Html.IHtmlContent RadioButtonFor<TModel,TResult> (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> htmlHelper, System.Linq.Expressions.Expression<Func<TModel,TResult>> expression, object value);
static member RadioButtonFor : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<'Model> * System.Linq.Expressions.Expression<Func<'Model, 'Result>> * obj -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function RadioButtonFor(Of TModel, TResult) (htmlHelper As IHtmlHelper(Of TModel), expression As Expression(Of Func(Of TModel, TResult)), value As Object) As IHtmlContent

Type Parameters

TModel

The type of the model.

TResult

The type of the expression result.

Parameters

htmlHelper
IHtmlHelper<TModel>

The IHtmlHelper<TModel> instance this method extends.

expression
Expression<Func<TModel,TResult>>

An expression to be evaluated against the current model.

value
Object

Value to include in the element. Must not be null.

Returns

A new IHtmlContent containing the <input> element.

Remarks

Combines HtmlFieldPrefix and the string representation of the expression to set <select> element's "name" attribute. Sanitizes the string representation of the expression to set element's "id" attribute. Converts the value to a String to set element's "value" attribute.

Applies to