如题,以下是代码:
<div class="editor-label">
@Html.Label("结束时间")
</div>
<div class="editor-field">
@Html.TextBox("EndDate")
@Html.ValidationMessageFor(model => model.EndDate)
</div>从数据库中读取数据,然后填充到textbook中的,我要问的是如何将 @Html.TextBox("EndDate") 设置成不可编辑(或只读)。因为这个数据是不能让用户编辑的。请各位高手们帮忙吧! 感谢万分!
<div class="editor-label">
@Html.Label("结束时间")
</div>
<div class="editor-field">
@Html.TextBox("EndDate")
@Html.ValidationMessageFor(model => model.EndDate)
</div>从数据库中读取数据,然后填充到textbook中的,我要问的是如何将 @Html.TextBox("EndDate") 设置成不可编辑(或只读)。因为这个数据是不能让用户编辑的。请各位高手们帮忙吧! 感谢万分!
这样也不行了,这样写直接在文本框里头输出 {readonly="true"} 这个信息。
@Html.TextBox("EndDate","", new { @readonly="readonly" })
分别对应Id(name)、值、样式或属性
他这样写Html.TextBox("EndDate",""是给你举个例子,这里的引里是让你写值的地方,你没写当然就是空的了@Html.TextBox("EndDate",Model.EndDate, new { @readonly="readonly" })
<div>@Html.TextBoxFor(x => x.AnimationUpload, new { @style = "width:80px",@readonly="True"})</div>这样可以,我已经实现这个效果啦或者用个My97日历控件啊!会自动验证是不是日期格式的