【发布时间】:2014-10-09 14:49:37
【问题描述】:
您好,我正在使用 Telerik Radfileexplorer。我正在使用它来仅上传 pdf 文档。但在上传文件后,用户可以重命名它们。该控件允许用户将文件扩展名 pdf aslo 重命名,然后如果他们将扩展名从 pdf 更改为其他文件,则文件将消失。我试图通过关注 Telerik 论坛中的一篇帖子来阻止这种行为,但文件仍然消失。代码和表单链接如下。
http://www.telerik.com/forums/renaming-file-disallow-extensions-cancel-move
function explorerMove(explorer, args)
{
//check if the event is fired by Rename command
if (args.get_newPath().search("/") < 0) {
if (!args.get_item().isDirectory()) { //check if the renamed item is file or folder
var orgExt = args.get_path().substring(args.get_path().lastIndexOf("."));
var newExt = args.get_newPath().substring(args.get_newPath().lastIndexOf("."));
if (orgExt != newExt) {
alert("Changing the file extension is not allowed");
args.set_cancel(true); //cancel further execution of the command
}
}
}
}
即使使用 args.set_cancel(true) 取消默认行为;文件扩展名仍在更改,文件正在消失。我想到了在 if(orgExt != newExt) 条件下将旧路径分配给新路径的方法,但我不知道该怎么做。
【问题讨论】:
-
你有 MVC 作为标签,你能确认你正在使用网络表单吗? ASP.NET AJAX 的 UI 不支持 MVC,这可能是代码无法正常工作的原因。
-
我没有使用 MVC 进行开发,我使用的是常规的 asp.net
标签: c# asp.net telerik radfileexplorer