小编Chr*_*s J的帖子

.NET core asp-for 单选按钮绑定到具有可点击标签的模型?

我想制作一个绑定到 asp.net core 中的模型的单选按钮列表。但是,我还希望独特的标签可单击并与每个单选按钮相关联。我有这个:

  <fieldset>
      <div>
          <span>
              <input type="radio" required asp-for="Email" value="EmailYes" /> <b>Send Email:</b> They will be sent an email.
          </span>
      </div>
      <div>
          <span>
              <input type="radio" required asp-for="Email" value="EmailNo" /> <b>Do Not Send Email:</b> They will not be sent an email.
          </span>
      </div>
  </fieldset>
Run Code Online (Sandbox Code Playgroud)

我尝试添加一个标签,如下所示:

  <label asp-for="EmailYes"><b>Send Email:</b> They will be sent an email. </label>
Run Code Online (Sandbox Code Playgroud)

但是当用户单击第二个标签时,它会选择第一个单选按钮。

谢谢。

.net html asp.net label

6
推荐指数
1
解决办法
6269
查看次数

标签 统计

.net ×1

asp.net ×1

html ×1

label ×1