如何使mvc4文本框只读? [英] how to make mvc4 textbox readonly?
本文介绍了如何使mvc4文本框只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在mvc 4中有一个带有以下行的查看页面
< td> ;
@ Html.LabelFor(M => Model.Patient.PatientID)
@ Html.TextBox(PatientID)
< / td>
在上面的行 @ Html.TextBox(PatientID)..PatientID
是viewbag的值。我需要的是使文本框只读。
解决方案
你好Murugappan,
剃刀,一切很简单,只需将@readonly属性添加到代码就可以了。
喜欢这个
@ Html.TextBox(< span class =code-string> PatientID, new {@ readonly = readonly})希望这会对你有所帮助。
问候,
RK
@readonly = true;
也应该有效 - http://slodge.blogspot.in /2010/11/razor-mvc3-readonly-textbox.html [ ^ ]。
@disabled =disabled - 完美无缺
Hi ,
I am having a view page in mvc 4 with following lines
<td> @Html.LabelFor(M => Model.Patient.PatientID) @Html.TextBox("PatientID") </td>
In above lines@Html.TextBox("PatientID").. "PatientID"
is value from viewbag. What i need is to make the textbox readonly.解决方案Hi Murugappan,
In razor, everything is easy just add @readonly attribute to the code will do the needful.
Like this
@Html.TextBox("PatientID",new { @readonly="readonly" })Hope this helps you a bit.
Regards,
RK
@readonly = true;
should also work - http://slodge.blogspot.in/2010/11/razor-mvc3-readonly-textbox.html[^].
@disabled = "disabled" - works perfect
这篇关于如何使mvc4文本框只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文