Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / Editor / Preventing users from deleting folders in the File Browser dialogs

Preventing users from deleting folders in the File Browser dialogs

Article Info

Rating: 5

Article information

Article relates to

 RadEditor for ASP.NET AJAX,
 Telerik.Web.UI

Created by

 Rumen Zhekov


HOW-TO
Prevent users from deleting folders in the File Browser dialogs

DESCRIPTION
Sometimes it is needed to allow users to delete files but prevent them from deleting folders in the File Browser dialogs. The solution below demonstrates how to implement this functionality.

SOLUTION
Here are the steps on how to disable the folder deletion in the File Browser dialogs of RadEditor:
1) register the external dialog files of RadEditor so that you can modify the FileBrowser.ascx file, e.g.

<telerik:RadEditor runat="server" ExternalDialogsPath="~/EditorDialogs" ID="RadEditor1">
    <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
</telerik:RadEditor>

2) Open the \EditorDialogs\FileBrowser.ascx file, locate the <RadFileExplorer> control and attach the OnClientDelete function to the OnClientDelete event property, e.g.

<telerik:RadFileExplorer ID="RadFileExplorer1" OnClientDelete="OnClientDelete" Height="450px" Width="400px" TreePaneWidth="150px"
runat="Server" EnableOpenFile="false" AllowPaging="true" />
<script type="text/javascript">
function OnClientDelete(oExplorer, args)
{
 var item = args.get_item();
 
 if (item.isDirectory())
 {
  args.set_cancel(true);
  alert("You cannot delete directories");
 }
}
</script>

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.