Skip to main content

How to: Upload a document in the working directory using drag-and-drop

  • 2 minutes to read

In some scenarios, it is necessary to load a document stored on a user’s hard disk to the ASPxRichEdit control. The ASPxRichEdit does not support this feature, but you can use a workaround described in this example. Note, that in this example the open document is saved to the Working Directory. If you need to open the document without saving to the Working Directory see this example.The ASPxUploadControl is developed to save client files to the server via a browser. This control includes the Advanced mode that allows users to load documents using drag-and-drop. The ASPxUploadControl’s ExternalDropZoneID property defines which HTML element is used to release files dragged from the client’s hardware. Using this property, you can invoke document loading by dragging it to the ASPxRichEdit control. When the ASPxUploadControl finishes loading the document, it is saved to the ASPxRichEdit’s WorkingDirectory and opened using the client-side command.

public partial class _Default : System.Web.UI.Page {
    protected void UploadControl_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e) {
        if (e.UploadedFile.IsValid) {
            string fileName = e.UploadedFile.FileName;
            e.UploadedFile.SaveAs(MapPath(RichEdit.WorkDirectory) + "\\" + fileName, true);
            e.CallbackData = fileName;
        }
    }
}