jeudi 5 juillet 2018

Model Data as label inside HTML checkbox

I'm working on a webpage with a series of accordion groups (user is applying for something). In one accordion group, I have a series of checkboxes that need to have dynamic labels. I'll be displaying 'Manager:', then the next part will be the manager email field, which may change depending on if the user changes that field or not. Now I've tried @Html.ValueFor(x => x.othermodel.field) and @Html.ValueForModel(Model.othermodel.field) and neither of them have displayed the value, as in the webpage displays "Manager: ". This accordion group is after the information input section, so the specific field has been populated. What would be the proper HTML syntax to display these model fields as the checkbox label?

<div class="checkbox" id="EmailDiv">
  <label for="ManagerEmail" class="control-label">
    <input id="ManagerEmail" name="Manager" type="checkbox" value="manager"/>
    Manager: @Html.ValueFor(x => x.othermodel.field)
  </label>
</div>

EDIT: Clarity




Aucun commentaire:

Enregistrer un commentaire