使用ASP .Net MVC 4,Razor View
我有一个CheckBoxFor:
<div class="editor-checkBox-field"> @Html.CheckBoxFor(model => model.Is2ndMailBody,new { @name = "secMailBody",@id = "secMailBody",@class = "secMailBody",@onclick = "disable(this.form.secMailBody)",@value = "Create Table",@text = "Create Table" }) </div>
但CheckBox本身正在显示.我如何显示文本CheckBox的用途?
我的模特有:
public bool IsChecked { get; set; }
javascript工作正常,css也.我只想知道如何显示此复选框的文字?
编辑1:
我想要复选框右侧的文本创建第二个邮件正文.
解决方法
答案1:只需将字符串放在CheckBox之后,如下所示.
<div class="checkBox"> <label> @Html.CheckBoxFor(m => m.Is2ndMailBody) Create Second Mail Body </label> </div>
答案2:在模型中,
[Display(Name = "Create Second Mail Body")] public bool Is2ndMailBody{ get; set; }
在视图中
<div> @Html.CheckBoxFor(m => m.IsChecked) @Html.LabelFor(m => m.Is2ndMailBody) </div>