Try our conversational search powered by Generative AI!

Several editable attributes on html element


I have an html element (input) that contains several html attributes (placeholder and two data- attributes to show info if element is empty or that input is not valid). I need to make these attributes editable, but I only found Html.EditAttributes helper, which allows me to edit ONE attribute from the list. Is there a way to make sereval attributes editable simultaneously?

Nov 07, 2019 9:59

You can do like this

@if (PageEditing.PageIsInEditMode)
    @Html.PropertyFor(x => x.AttributeProperty1)
    @Html.PropertyFor(x => x.AttributeProperty2)
    @Html.PropertyFor(x => x.AttributeProperty3)
    <input type="text" data-attr1="@Model.AttributeProperty1" data-attr1="@Model.AttributeProperty2"  data-attr1="@Model.AttributeProperty3" />

It's just a sample code as hint, you can modify as your need. Ultimately the solution is to use the PageEditing.PageIsInEditMode

Nov 07, 2019 11:33

Great! I didn't think about checking editing mode but this solution does exactly what I had needed. Thanks!

Nov 07, 2019 12:12
Praful Jangid - Nov 07, 2019 13:01
Your welcome :)
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.