I’m working on a strongly-typed edit form for a MVC model that contains a collection of child models (Document contains many LocalizedDocuments). Each document can contain 0, 1, or many localized documents, and every localized document has an input type=”file” to allow the user to upload a new version of the file.
To render the edit fields for each LocalizedDocument I have a strongly-typed partial view that contains the fields for the LocalizedDocument, and then in my edit view use Html.EditorFor(model => model.Document.LocalizedDocuments).
When the form is posted, each of my LocalizedDocument fields are prefixed with LocalizedDocument[i], as expected. However, how can I get it so the file input is also prefixed with LocalizedDocument[i], so I can relate the file upload to the appropriate LocalizedDocument?
Tell me if I’m interpreting this question wrong. You have documents that you need to upload that belongs to a parent table or you need to assign these documents a specific id after uploading multiple of them?
I’ll be using Uploadify.
You will have to know the Id of the LocalizedDocument. You will also only be able to upload 1 at a time. (each file is a separate server call)
First you have to assign the Id of the LocalizedDocument to the data that will be sent to the server.
Controller: