我想提交一個表單,其中一個屬性是文件列表。在的ActionResult已成功完成如何通過kendo.upload和MVC中的表單上傳文件後調用JavaScript?
後,我需要證明有通過的Javascript觸發一個成功的消息。
如果我使用Ajax.Begin形式示出的JavaScript消息,但如果使用Html.BeginForm文件被髮送的文件不會被髮送到的ActionResult,在另一方面,但是我我無法調用JavaScript函數,因此我無法觸發我的成功消息。
這裏是我的看法:
@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>
}
我的行動
[HttpPost]
public ActionResult Action(Model model)
{
//do something
result = new BaseJsonData();
result.HasCompletedSuccessfully = true;
return this.Json(result);
}
我的模型
public class EventModel
{
public string Notes { get; set; }
public IEnumerable<HttpPostedFileBase> EventFiles { get; set; }
}
我的javascript:
onSuccess: function (data) {
if (data.HasCompletedSuccessfully) {
//show message extention
}
}
感謝提前:)
Schewns
嘗試在聲明@(Html.Kendo()。Upload()。Name('EventFiles'))中添加事件。事件(「onComplete」)並創建一個onComplete在JavaScript中的功能,一旦上傳完成後將被調用 – Sushil