.Net Core单选按钮标签助手

时间:2019-02-12 14:39:45

标签: c# asp.net asp.net-mvc asp.net-core

具有与下面类似的页面设置,HasAnimal始终绑定为false-尽管被选中-任何想法?

cs

public class MyViewModel
{
     public bool HasAnimal { get; set; }
     public async Task<IActionResult> OnPostAsync() {}
}

cshtml

<label>Yes</label>
<input asp-for="HasAnimal" type="radio" value="true" checked />
<label>No</label>
<input asp-for="HasAnimal" type="radio" value="false" />

0 个答案:

没有答案