Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 3-Oct-18 0:35am
v4

@readonly = "true"

Working Perfect
 
Share this answer
 
Comments
CHill60 3-Oct-18 11:02am    
If you want to comment on a solution then use the "Have a Question or Comment?" link next to it. Don't repost the solution
@disabled = "disabled" - works perfect
 
Share this answer
 
 
Share this answer
 
Hi Murugappan,

In razor, everything is easy just add @readonly attribute to the code will do the needful.
Like this
C#
@Html.TextBox("PatientID",new { @readonly="readonly" })
Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v2
Comments
Abhinav S 7-Nov-13 3:49am    
5.
♥…ЯҠ…♥ 7-Nov-13 4:41am    
;-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900