Delen via


HtmlHelper.RadioButton Method

Definition

Returns an <input> element of type "radio" for the specified expression. Adds a "value" attribute to the element containing the first non-null value found in: the value parameter, or the htmlAttributes dictionary entry with key "value". Adds a "checked" attribute to the element if value matches the first non-null value found in: the htmlAttributes dictionary entry with key "checked", the ModelState entry with full name, the ViewData entry with full name, or the expression evaluated against Model. If isChecked is non-null, instead uses the first non-null value found in: the ModelState entry with full name, or the isChecked parameter. See Name(String) for more information about a "full name".

public:
 virtual Microsoft::AspNetCore::Html::IHtmlContent ^ RadioButton(System::String ^ expression, System::Object ^ value, Nullable<bool> isChecked, System::Object ^ htmlAttributes);
public Microsoft.AspNetCore.Html.IHtmlContent RadioButton (string expression, object value, bool? isChecked, object htmlAttributes);
abstract member RadioButton : string * obj * Nullable<bool> * obj -> Microsoft.AspNetCore.Html.IHtmlContent
override this.RadioButton : string * obj * Nullable<bool> * obj -> Microsoft.AspNetCore.Html.IHtmlContent
Public Function RadioButton (expression As String, value As Object, isChecked As Nullable(Of Boolean), htmlAttributes As Object) As IHtmlContent

Parameters

expression
String

Expression name, relative to the current model.

value
Object

If non-null, value to include in the element. Must not be null if isChecked is also null and no "checked" entry exists in htmlAttributes.

isChecked
Nullable<Boolean>

If true, radio button is initially selected. Must not be null if value is also null and no "checked" entry exists in htmlAttributes.

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.

Implements

Applies to