Events
The RadFileExplorer control provides the following server side events:
ItemCommand
Called on the following commands executed by the user:
- UploadFile - fired before each uploaded file is saved
- CreateDirectory - fired before the file explorer creates a new folder
- DeleteDirectory - fired before the file explorer deletes a folder
- DeleteFile - fired before a file is deleted
- MoveFile - fired before a file is moved/renamed
- MoveDirectory - fired before a directory is moved/renamed
- CopyFile - fired before a file is copied
- CopyDirectory - fired before the file explorer copies a folder
<telerik:RadFileExplorer RenderMode="Lightweight" runat="server" ID="RadFileExplorer1" Width="575px" EnableCopy="true"
Height="375px" OnItemCommand="RadFileExplorer1_ItemCommand">
<Configuration ViewPaths="~/ROOT/" DeletePaths="~/ROOT/" UploadPaths="~/ROOT/" />
</telerik:RadFileExplorer>
protected void RadFileExplorer1_ItemCommand(object sender, RadFileExplorerEventArgs e)
{
switch (e.Command)
{
case "UploadFile": break;
case "CreateDirectory": break;
case "DeleteDirectory": break;
case "DeleteFile": break;
case "MoveFile": break;
case "MoveDirectory": break;
case "CopyFile": break;
case "CopyDirectory": break;
}
// e.Cancel = true; // Cancel the operation
}
You can use the
ItemCommand
event to validate the user actions in order to tighten security. You can find an example in the Security help article.
ExplorerPopulated
This event is fired twice - once when the TreeView's items are populated and second time when the Grid's items are populated. The ControlName property contains the name of the control, which will consume the populated data (e.List). This event can be used to sort the FileExplorer's items for example.
<telerik:RadFileExplorer RenderMode="Lightweight" runat="server" ID="RadFileExplorer1" Width="575px" EnableCopy="true"
Height="375px" OnExplorerPopulated="RadFileExplorer1_ExplorerPopulated">
<Configuration ViewPaths="~/ROOT/" DeletePaths="~/ROOT/" UploadPaths="~/ROOT/" />
</telerik:RadFileExplorer>
protected void RadFileExplorer1_ExplorerPopulated(object sender, Telerik.Web.UI.RadFileExplorerPopulatedEventArgs e)
{
switch (e.ControlName)
{
case "tree":
{// The TreeView control will be populated
// Sorts the items shown in the Tree by name
e.List.Sort(delegate(FileBrowserItem fileBrowserItem1, FileBrowserItem fileBrowserItem2)
{
return fileBrowserItem1.Name.CompareTo(fileBrowserItem2.Name);
});
}; break;
case "grid":
{// The Grid control will be populated
// Sorts the items shown in the Grid by name
e.List.Sort(delegate(FileBrowserItem fileBrowserItem1, FileBrowserItem fileBrowserItem2)
{
return fileBrowserItem1.Name.CompareTo(fileBrowserItem2.Name);
});
// DESC order
e.List.Reverse();
}; break;
}
}
You can also handle some of the events of the controls nested in RadFileExplorer by accessing them in the Page_Load event through the RadFileExplorer object. More details about the controls nested in RadFileExplorer can be found here: