Skip to main content
.NET 6.0+

File Attachment Properties

  • 3 minutes to read

Add the File Attachments Module to your application to use the file attachment functionality. The following lessons contain a detailed explanation on how to use the File Attachments Module:

A business object that contains file data should implement the IFileData interface to display the XAF file data property editor (the FileDataPropertyEditor class). For example, FileDataPropertyEditor is shown for properties of the built-in FileData type. (The FileData class implements the IFileData interface.)

Note

You can find an example of the File Attachment property editor in the Property Editors | File Attachment Properties section of the Feature Center demo installed with XAF. The default location of the application is %PUBLIC%\Documents\DevExpress Demos 23.2\Components\XAF\FeatureCenter.NETFramework.XPO.

Examples

WinForms

File Attachment Properties WinForms

Each WinForms Property Editor has a control that displays the corresponding property in a Detail View, and a repository item that displays the property in a List Editor and supports in-place editing.

FileDataPropertyEditor

Control
FileDataEdit - a ButtonEdit descendant. The editor uses OpenFileDialog to attach a file.
Repository Item
RepositoryItemFileDataEdit - a RepositoryItemButtonEdit descendant.
Description
The editor allows a user to perform the Open, SaveTo, and ClearContent Actions that FileAttachmentController contains. Use the editor’s context menu to execute these Actions. You can also click the editor’s button or press Enter to execute the Open Action.

ASP.NET Web Forms

File Attachment Properties Web Forms

Each ASP.NET Web Forms Property Editor has two different controls that display a property in a Detail View and in Edit mode. These controls are listed below.

FileDataPropertyEditor

View Mode Control
A FileDataEdit control that uses the HtmlAnchor control to download a file.
Edit Mode Control
A FileDataEdit control that uses ASPxUploadControl to upload a new file and the HtmlAnchor control to download a file. In edit mode, FileDataEdit also contains the Change File and Clear buttons of the ASPxButton type.
Description
FileDataPropertyEditor displays the property’s value as a link with the file name. A user can click the link to download the file. In edit mode, the Change File and Clear buttons are shown. FileAttachmentController contains corresponding Actions.

FileDataPropertyEditor does not show the upload progress if the ImmediatePostDataAttribute is applied to the related FileData property or the IModelCommonMemberViewItem.ImmediatePostData option is enabled for the current View Item in Model Editor.

ASP.NET Core Blazor

File Attachment Properties Blazor

FileDataPropertyEditor

FileDataPropertyEditor uses custom Blazor components to implement the editor’s functionality. If you need to customize its layout or behavior, implement the custom property editor as described in the following topic: How to: Implement a Property Editor Based on a Custom Component (Blazor).

FileDataPropertyEditor displays the property’s value as a link with the file name. A user can click the link to download the file. In the Detail View, the Select File and Clear buttons are shown. FileAttachmentController contains corresponding Actions. A user should save changes after a file upload to display a link instead of a plain text file name.