IHtmlHelper<TModel>.RadioButtonFor<TResult> 方法

定義

傳 < 回指定 expression 之 類型為 「radio」 的輸入 > 專案。 將 「value」 屬性加入至包含中第一個非 null 值的專案: value 參數,或索引鍵為 「value」 的 htmlAttributes 字典專案。 如果 value 符合 中找到的第一個非 null 值,則會將 「checked」 屬性新增至元素: htmlAttributes 索引鍵為 「checked」 的字典專案,或 ModelState 具有完整名稱的專案。 如果 expression 評估為非 null 值,請改用 中找到的第一個非 null 值: ModelState 具有完整名稱的專案,或 expression 針對 評估的 Model 。 如需有關「完整名稱」的詳細資訊,請參閱 NameFor<TResult>(Expression<Func<TModel,TResult>>) 。 將 「value」 屬性加入至包含 參數的專案 value

public:
generic <typename TResult>
 Microsoft::AspNetCore::Html::IHtmlContent ^ RadioButtonFor(System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression, System::Object ^ value, System::Object ^ htmlAttributes);
public Microsoft.AspNetCore.Html.IHtmlContent RadioButtonFor<TResult> (System.Linq.Expressions.Expression<Func<TModel,TResult>> expression, object value, object htmlAttributes);
abstract member RadioButtonFor : System.Linq.Expressions.Expression<Func<'Model, 'Result>> * obj * obj -> Microsoft.AspNetCore.Html.IHtmlContent
Public Function RadioButtonFor(Of TResult) (expression As Expression(Of Func(Of TModel, TResult)), value As Object, htmlAttributes As Object) As IHtmlContent

類型參數

TResult

結果的類型 expression

參數

expression
Expression<Func<TModel,TResult>>

要針對目前模型評估的運算式。

value
Object

要包含在 專案中的值。 必須不是 null

htmlAttributes
Object

Object,其中包含 專案的 HTML 屬性。 或者, IDictionary<TKey,TValue> 包含 HTML 屬性的實例。

傳回

新的 IHtmlContent , < 其中包含輸入 > 專案。

備註

HtmlFieldPrefix結合 和 的 expression 字串表示,以設定 < select > 元素的 「name」 屬性。 清理 的 expression 字串表示,以設定專案的 「id」 屬性。

適用於