Currently, I am faced with a challenge while trying to submit a form that includes a List of files as one of its properties.
Upon successful completion of the ActionResult, I need to display a success message using Javascript.
When I utilize Ajax.Begin form, the Javascript message displays correctly, but unfortunately, the files are not sent to the ActionResult. On the other hand, if I opt for Html.BeginForm, the files get sent, however, it prevents me from calling the javascript function and subsequently hindering the triggering of my success message.
Below is my view:
@using (Html.BeginForm("Action", "Controller", FormMethod.Post,
new { id = "exceptionForm", enctype = "multipart/form-data" }))
{
@Html.TextAreaFor(m => m.Notes)
@(Html.Kendo().Upload()
.Name("EventFiles")
)
<div >
<button href="#">
submit
</button>
</div>
}
My Action
[HttpPost]
public ActionResult Action(Model model)
{
//do something
result = new BaseJsonData();
result.HasCompletedSuccessfully = true;
return this.Json(result);
}
My model
public class EventModel
{
public string Notes { get; set; }
public IEnumerable<HttpPostedFileBase> EventFiles { get; set; }
}
My javascript:
onSuccess: function (data) {
if (data.HasCompletedSuccessfully) {
//show message extention
}
}
I appreciate any help in advance :)
Schewns