MVC control bindings

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

MVC control bindings

I'm working on moving NeatUpload into my MVC application, but haven't had any luck binding the controls to my model properties.

The model looks like this:
   public class FileUploadModel
      public InputFile InputFile { get; set; }

In the view, my input file control looks like this:
   File: <Upload:InputFile ID="InputFile" name="InputFile" runat="server" />

But the InputFile control is always null when I try to access it in the controller.
      public ActionResult FileUpload(FileUploadModel model)
         var file = model.InputFile;

I have a feeling this might be because the control id and name get auto-generated when the view is rendered. So instead of this:
   File: <Upload:InputFile ID="InputFile" name="InputFile" runat="server" />

I get this:
   File: <input type="file" name="NeatUpload_269887C3EBF07E325B5D0099E9D1013C-ctl00$MainContent$InputFile" id="MainContent_InputFile"

Which MVC can't match to my model attributes. Anyone have a work-around for this?