Loading EditorFor template dynamically via Ajax

I have a Model object with a list of Sub objects. I need to upload form fields for an auxiliary object to the page and provide a link to dynamically add form fields for the second object. Thus, in other words, several auxiliary objects can be created using one form and one record.

My first thought was only to put the form fields in a partial view and load the view through Ajax.ActionLink. This worked, but the problem occurs when trying to uniquely identify each object in the collection and bind the collection of objects to the postback. To do this, it seems correct to use the @ Html.EditorFor () helper, but I do not know how to call it via Ajax to dynamically add an object editor template to the page when the link is clicked.

+3
source share
1 answer

It looks like you were on the right track regarding a partial view, you just need to figure out the property of the names of your inputs so that you can correctly bind to the collection of objects.

, , , google - .

0

All Articles