I have a simple form:
@Model MyViewModel
<form method="post" action='@Url.Action("Submit")'>
<div class="demo-section k-content">
@Html.TextBoxFor(x => x.SomeRequiredField);
@(Html.Kendo().Upload() .Name("files") .HtmlAttributes(new { aria_label = "files" }) )
<p style="padding-top: 1em; text-align: right"><input type="submit" value="Submit" class="k-button k-primary" /></p>
</div>
</form>
public ActionResult Submit(MyViewModel vm, IEnumerable<HttpPostedFileBase> files){
if(ModelState.Valid) {
... do stuff
} else {
return View(vm);
}
}
If I select a bunch of files in my upload control, and push the Submit button, suppose validation failed and the view is posted back, however my selected files are lost and I have to reselect them.
How do I restore the previously selected files in the file upload control (synchronous mode) when the form fails validation and is posted back?