【发布时间】:2015-04-19 10:22:03
【问题描述】:
我想使用 Telerik asp mvc 产品上传文件。文件上传后,我想显示剑道通知,但由于我无法从控制器调用 ajax 方法,我在执行此操作时遇到了问题,有什么帮助吗?
【问题讨论】:
-
您希望消息显示在页面 POST 之后还是之前?
标签: asp.net-mvc notifications telerik kendo-asp.net-mvc
我想使用 Telerik asp mvc 产品上传文件。文件上传后,我想显示剑道通知,但由于我无法从控制器调用 ajax 方法,我在执行此操作时遇到了问题,有什么帮助吗?
【问题讨论】:
标签: asp.net-mvc notifications telerik kendo-asp.net-mvc
将消息保存在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
【讨论】: