DropZone
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.2.0.0)
Provides a drag-and-drop or keyboard-accessible upload queue using Wisej upload transport.
- C#
- VB.NET
public class DropZone : Control, IWisejHandler
Public Class DropZone
Inherits Control
Implements IWisejHandler
Files are checked on selection and again against the actual HTTP upload. Extension checks are not content inspection. MaxFiles includes accepted queued and completed files until removed or cleared. Zero-byte files are rejected because the Wisej upload transport skips them. Files upload sequentially; cancel stops the current request and pauses the queue. Server request-body limits also apply. The application owns persistence and must consume received streams in UploadCompleted.
Example:
var zone = new DropZone {
AllowedExtensions = new[] { ".csv", ".xlsx" }, MaxFileSize = 25 * 1024 * 1024,
MaxFiles = 5, Multiple = true, UploadMode = DropZoneUploadMode.Manual
};
zone.UploadCompleted += (s, e) => Console.WriteLine(e.UploadedFile.ContentLength);
Controls.Add(zone);
Constructors
DropZone()
Initializes a new instance of DropZone.
Properties
AllowedExtensions
String[]: Gets or sets accepted extensions, for example .csv. Matching is case insensitive; an empty array accepts all extensions.
Values are normalized to lower case with a leading dot. MIME patterns and paths are not supported. Both getters and setters copy the array. Changing a rule revalidates pending uploads when received.
CanceledText
String: Gets or sets the localized override for the "Canceled" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.
Compact
Boolean: Gets or sets a compact single-row upload target. (Default: False)
CompletedText
String: Gets or sets the localized override for the "Completed" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.
DefaultSize
Size: Gets the default surface size.
EmptyFileText
String: Gets or sets the validation message for an empty file. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
FileMetadataMismatchText
String: Gets or sets the validation message when received file metadata differs from the approved file. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
FileNotApprovedText
String: Gets or sets the message for an upload whose approval is no longer valid. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
FileTooLargeText
String: Gets or sets the validation message for a file exceeding MaxFileSize. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
FileTypeNotAllowedText
String: Gets or sets the validation message for a disallowed file extension. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
HintText
String: Gets or sets the main plain-text upload prompt. (Default: null)
Null uses the built-in text for the current UI culture. An empty string suppresses the text.
InvalidFileNameText
String: Gets or sets the validation message for an invalid file name. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
Example:
var control = new DropZone();
control.InvalidFileNameText = "Choose a file with a valid name.";
control.InvalidFileNameText = null; // Restore the built-in localized text.
MaxFiles
Int32: Gets or sets the maximum accepted queue entries, including completed files. Zero means unlimited. (Default: 0)
MaxFileSize
Int64: Gets or sets the maximum length of each file in bytes. Zero means unlimited. (Default: 0)
MaxFilesReachedText
String: Gets or sets the validation message for exceeding the permitted file count. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
Multiple
Boolean: Gets or sets whether more than one file can be accepted at a time. (Default: True)
QueuedText
String: Gets or sets the localized override for the "Queued" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.
RemoveFileText
String: Gets or sets the localized override for the "Remove {0}" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the file name. Literal braces can be written as {{ and }}.
ShowFileList
Boolean: Gets or sets visibility of the retained file list. (Default: True)
SingleFileRequiredText
String: Gets or sets the validation message when an upload request does not contain exactly one file. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
SubHintText
String: Gets or sets the secondary plain-text hint about accepted files. (Default: "")
UploadFailedText
String: Gets or sets the generic upload failure message. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
UploadingText
String: Gets or sets the localized override for the "Uploading" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.
UploadMode
DropZoneUploadMode: Gets or sets automatic or explicitly triggered uploading. (Default: Auto)
ValidatingText
String: Gets or sets the localized override for the "Validating" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.
Methods
CancelUpload()
Aborts the current file and pauses remaining files. Upload resumes remaining pending files.
Clear()
Aborts any active upload and removes all entries. Application-saved files are not deleted.
OnFileClick(e)
Raises FileClick.
| Parameter | Type | Description |
|---|---|---|
| e | DropZoneFileEventArgs | Metadata for the activated file. |
OnFileRemoved(e)
Raises FileRemoved.
| Parameter | Type | Description |
|---|---|---|
| e | DropZoneFileEventArgs | File event data. |
OnFilesAdded(e)
Raises FilesAdded.
| Parameter | Type | Description |
|---|---|---|
| e | DropZoneFileEventArgs | File event data. |
OnUploadCompleted(e)
Raises UploadCompleted.
| Parameter | Type | Description |
|---|---|---|
| e | DropZoneFileEventArgs | File event data. |
OnUploadFailed(e)
Raises UploadFailed.
| Parameter | Type | Description |
|---|---|---|
| e | DropZoneFileEventArgs | File event data. |
OnUploadProgress(e)
Raises UploadProgress.
| Parameter | Type | Description |
|---|---|---|
| e | DropZoneFileEventArgs | File event data. |
OnValidationFailed(e)
Raises ValidationFailed.
| Parameter | Type | Description |
|---|---|---|
| e | DropZoneFileEventArgs | File event data. |
OnWebEvent(e)
Dispatches browser queue events.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Browser event data. |
OnWebRender(config)
Renders upload settings without replacing the browser queue.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Client configuration. |
Upload()
Uploads all accepted pending files. This does not open a file dialog.
Events
FileClick
EventHandler<DropZoneFileEventArgs> Occurs when the user clicks an accepted file or activates it with Enter or Space.
Available for accepted queued, uploading, completed, failed, and canceled files until removed or cleared. The remove button does not raise this event. File contains the server-approved identity, name, and size; UploadedFile is null. Persist file content during UploadCompleted and use File.Id to find that content later. No preview or download is opened automatically.
Example:
zone.FileClick += (sender, e) => Console.WriteLine($"Selected {e.File.Name} ({e.File.Id})");
FileRemoved
EventHandler<DropZoneFileEventArgs> Occurs when the user removes a file from the list.
FilesAdded
EventHandler<DropZoneFileEventArgs> Occurs once for each file accepted into the queue.
UploadCompleted
EventHandler<DropZoneFileEventArgs> Occurs after server validation of the received file. Read its stream during this event.
UploadFailed
EventHandler<DropZoneFileEventArgs> Occurs when an upload fails or is canceled.
UploadProgress
EventHandler<DropZoneFileEventArgs> Occurs when the browser reports progress for an accepted file.
ValidationFailed
EventHandler<DropZoneFileEventArgs> Occurs when file metadata or the received upload fails validation.
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| IDropTarget | Controls that support drag & drop operations implement this interface. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejControl | All wisej controls derived from the Control class must implement this interface. |
| IWisejHandler | Represents a Wisej component that is capable of handling postback requests from the client. |
| IWisejSerializable | Allows an object to serialize itself. |