Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pgregorynz/5662342 to your computer and use it in GitHub Desktop.
Save pgregorynz/5662342 to your computer and use it in GitHub Desktop.
Because MVC doesnt have an EditorFor input types of files this little trick lets you get around that rather than having to hardcode your input. You change the type of the texbox to be of type file.
@* the model property for Upload is of type HttpPostedFileBase *@
@* rather than doing having to hardcode <input type="file" name="upload" id="upload" /> *@
@Html.TextBoxFor(model => model.Upload, new{type="file"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment