我们如何使用 asp mvc kendo 文件上传并返回 Kendo 通知?

How can we use asp mvc kendo file upload and returning Kendo notification?

我想使用 telerik asp mvc 产品上传文件。文件上传后,我想显示 kendo 通知,但由于我无法从控制器调用 ajax 方法,我在执行此操作时遇到了麻烦,有什么帮助吗?

将消息保存在 TempData

TempData["KendoMsg"] = String.Format("{0} has been saved",model.fileName);

并在返回视图中

@section scripts{
   <script>
      $(function(){
          if(@TempData["KendoMsg"] != ""){
              popupNotification.show(@TempData["KendoMsg"]);
          }
      });
   </script>
}

如果您不等待 POST 那么您可以直接使用

<script>
$("#files").kendoUpload({
    async: {
        saveUrl: "save",
        removeUrl: "remove"
    },
    success: onSuccess
});

function onSuccess(e) {
    // Array with information about the uploaded files
    var files = e.files;

    if (e.operation == "upload") {
        popupNotification.show("Successfully uploaded " + files.length + " files");
    }
}
</script>

http://docs.telerik.com/kendo-ui/api/javascript/ui/upload#events-success