I’m working on a website where the user should be able to fill out a dynamic expanding form.
I would add a row with greyed out fields and when the user gives focus to one of those field the following javascript would add the line
<tr class="unSelected">
<input name="id[]">
<input name="blabla[]">
</tr>
$('.unSelected').focusin(function () {
if ($(this).hasClass('unSelected')) {
var row = $(this).clone(true);
$(this).after(row);
$(this).removeClass('unSelected');
}
});
but how would one do this using razor and asp.net, as the objects wont be autogenerated then?
In ASP.NET MVC, if you have a model class like:
And your javascript adds rows like so:
The default model binder in MVC should resolve it just fine when it gets posted