Back to Devexpress

ASPxFileManager.FolderCreating Event

aspnet-devexpress-dot-web-dot-aspxfilemanager-0c723473.md

latest3.8 KB
Original Source

ASPxFileManager.FolderCreating Event

Fires on the server side before a folder is created and allows you to cancel the action.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event FileManagerFolderCreateEventHandler FolderCreating
vb
Public Event FolderCreating As FileManagerFolderCreateEventHandler

Event Data

The FolderCreating event's data class is FileManagerFolderCreateEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the action that raised the event should be canceled. Inherited from FileManagerActionEventArgsBase.
ErrorTextGets or sets a text for the explanatory message. Inherited from FileManagerActionEventArgsBase.
NameGets the name of the newly created folder.
ParentFolderGets the parent folder for the newly created item.

Remarks

Before each time a folder is created on the server side, the FolderCreating event occurs, allowing you to cancel folder creation. You can use the event parameter’s properties to identify a name (FileManagerFolderCreateEventArgs.Name) and a parent folder (FileManagerFolderCreateEventArgs.ParentFolder) of the newly created folder. To cancel the create operation, set the FileManagerActionEventArgsBase.Cancel property to true. In order to show the message explaining the reason for the cancellation, specify the FileManagerActionEventArgsBase.ErrorText property.

Example

The code below demonstrates how you can handle the FolderCreating event, to prevent creation of child folders for the root folder.

The image below shows the result.

csharp
protected void ASPxFileManager1_FolderCreating(object source, DevExpress.Web.FileManagerFolderCreateEventArgs e) {
      if (e.ParentFolder.FullName == "Files")
            e.Cancel = true;
            e.ErrorText = "You cannot create child folders for the root folder";
}
aspx
<dx:ASPxFileManager ID="ASPxFileManager1" runat="server" OnFolderCreating="ASPxFileManager1_FolderCreating">
            <Settings RootFolder="~/Content/FileManager/Files" ThumbnailFolder="~\Thumb" />
            <SettingsEditing AllowCreate="True" />
</dx:ASPxFileManager>

See Also

FolderCreating

FolderCreated

File Manager

ASPxFileManager Class

ASPxFileManager Members

DevExpress.Web Namespace