asp.net mvc 5 - Dynamic Naming of DropDownListFor -
i have address view users enter addresses both billing , shipping. on address model have:
public string addresstype { get; set; }
then on create account view have:
<div class="pure-control-group"> @html.action("init", "address", new {addresstype="billing"}) </div> <div class="pure-control-group"> @html.action("init", "address", new {addresstype="shipping"}) </div>
in address view have number of input
controls render expected have country dropdown list want dynamically name (the control using html helper for):
@html.dropdownlistfor(m => m.selectedcountryid, new selectlist(model.validcountries, "countryid", "countryname", model.selectedcountryid), null, new {name=model.addresstype + "_selectedcountryid", id=model.addresstype + "_selectedcountryid"})
however when renders end with:
<select id="billing_selectedcountryid" name="selectedcountryid">
i want:
<select id="billing_selectedcountryid" name="billing_selectedcountryid">
i have read using upper case n name fixes others have said adds property:
<select id="billing_selectedcountryid" name="selectedcountryid" name="billing_selectedcountryid">
everything have read bit confusing , can't make out if found fix, there anyway round this?
Comments
Post a Comment