<div class="editor-label" style="position:static">
<%: Html.LabelFor(Model => Model.Date, "Date")%>
<span style="padding-left:52px">
<%: Html.TextBoxFor(Model => Model.Date)%>
Here i want to set the readonly property to the textbox on a button click/Action Click. how do i do it.
At the initial page the data is been displayed as readonly and on the edit button click. This should be changed to editable textbox.I have almost seven textboxes i need to do the same for all.
If I understand your question correctly, this can be accomplished with a little javascript. Here’s a simple example.
Render each textbox as readonly on page load:
Add a click handler for your edit button that will remove the readonly attribute from each textbox: