I have two instances of an Address.ascx
control in an ASP.NET MVC page.
<h1>Shipping Address</h1>
<% Html.RenderPartial("Controls/AddressControl"); %>
<h1>Billing Address</h1>
<% Html.RenderPartial("Controls/AddressControl"); %>
Of course, with the code exactly like this I'll end up with the same IDs for each field in the address. I can easily append a string to the ID of the fields so I'd have 'Street1_billing'
and 'Street1_shipping'
, but I'm not clear how to map this to the model.
Whats the best solution to mapping a model to an array of items (in this case only 2). I'm not aware of any ASP.NET 'out of the box' solution for this.
Note: This is slightly similar to this question and I could use this solution from Scott Hanselman, but its not exactly what I want. In my case I know I have two items, so its essentially a 2 item array but I'm wondering if there is a slightly more elegant solution.
PS. I'm sure this has been asked many times before, but I just cant seem to put in the right search terms. Please link this question if you're aware of dupes!