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:
- Attach files to objects in WinForms and ASP.NET Core Blazor applications.
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.)
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.1\Components\XAF\FeatureCenter.NETFramework.XPO.
- FileDataEdit - a ButtonEdit descendant. The editor uses OpenFileDialog to attach a file.
- Repository Item
- RepositoryItemFileDataEdit - a RepositoryItemButtonEdit descendant.
- 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
- 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.
- 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
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.