@if
Razor ビューでラジオ ボタンの句を使用して、 HTML を表示することができます。
@if (Model.Step.RadioButton1 == Step.Enum1.Choice1)
{
....
}
ただし、チェックボックスを次のように処理する場合:
@if (Model.Step.CheckBox1 == Step.Enum2.Choice1)
{
....
}
エラーが発生します:
演算子 '==' はタイプ 'System.Collections.Generic.List' のオペランドには適用できません
私はエラーを理解しています{ }
..
他のコードが関連しているかどうかはわかりませんが、役立つ場合は投稿します。ありがとう。
チェックボックスのコード:
public enum Choices
{
[Display(Name = "Choice 1")]
Choice1,
....
}
public class ChoicesSelectorAttribute : SelectorAttribute
{
public override IEnumerable<SelectListItem> GetItems()
{
return Selector.GetItemsFromEnum<Choices>();
}
}
[Mandatory(ErrorMessage = "Please select at least one type")]
[ChoicesSelector(BulkSelectionThreshold = 15)]
public List<string> CheckBox1 { get; set; }