5
I’ve got a lot of doubt and I barely know where to start, so I’m going to go to college:
I have a page cshtml
(I’m using Asp.net-mvc). It has a list, assuming that the elements are A, B, C, D, E. The value of these elements comes from the database and both are already being loaded correctly.
Assuming I want to make available for editing the values 'B' and’D', how do I do? And how do I add the checkbox
on that list?
EDIT
I’m using this property
new { htmlAttributes = new { @readonly = "readonly" } }
But it didn’t work. It still allows editing, follows as this my code.
<td> @Html.EditorFor(modelItem => item.obs, new { htmlAttributes = new { @readonly = "readonly" } })</td>
After you put the
EditorFor
, how was the generated HTML? You can edit your question and put this too?– Leonel Sanches da Silva
<input class="text-box single-line" id="item_obs" name="item.Obs" type="text" value="test test"> this was the generated html.
– Genisson
I ended up seeing that the property editorFor does not have properties that disable it, so I switched to textBoxFor, the only apparent change is that all my values will be converted to text
– Genisson
It wouldn’t be the case to use @Html.Displayfor for items you don’t want changed?
– RSinohara
@Yes, you’re right. You’d have to rewrite the template editor to support read-only. I will update my answer.
– Leonel Sanches da Silva
then @Rsinohara, but there is a field where a certain type of user can edit and the other cannot, but the text already helps and "solved" the problem.
– Genisson