MVC RadiobuttonFor Razor how to make label click able?
问题 I'm trying to make a radiobuttonlist in razor syntax so far I have come up with this @foreach (var p in Model) { <div id="projectList" class="col-lg-5"> @Html.RadioButton("name", "1", false, new { onCLick = "ShowOption(this)", id = p.id.ToString() }) @Html.Label(p.id.ToString(), p.name) </div> } but the label isn't associated with the radiobutton. 回答1: Your foreach loop is not generating for attribute for the label (and if you removed new { id = p.id.ToString() } from the RadioButton method,