Skip to main content
Version: 4.2

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.

public class DropZone : Control, 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​

Instance member DropZone()​

Initializes a new instance of DropZone.

Properties​

Instance member 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.

Instance member 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.

Instance member Compact​

Boolean: Gets or sets a compact single-row upload target. (Default: False)

Instance member 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.

Protected member DefaultSize​

Size: Gets the default surface size.

Instance member 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.

Instance member 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.

Instance member 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.

Instance member 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.

Instance member 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.

Instance member 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.

Instance member 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.

Instance member MaxFiles​

Int32: Gets or sets the maximum accepted queue entries, including completed files. Zero means unlimited. (Default: 0)

Instance member MaxFileSize​

Int64: Gets or sets the maximum length of each file in bytes. Zero means unlimited. (Default: 0)

Instance member 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.

Instance member Multiple​

Boolean: Gets or sets whether more than one file can be accepted at a time. (Default: True)

Instance member 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.

Instance member 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 }}.

Instance member ShowFileList​

Boolean: Gets or sets visibility of the retained file list. (Default: True)

Instance member 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.

Instance member SubHintText​

String: Gets or sets the secondary plain-text hint about accepted files. (Default: "")

Instance member 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.

Instance member 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.

Instance member UploadMode​

DropZoneUploadMode: Gets or sets automatic or explicitly triggered uploading. (Default: Auto)

Instance member 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​

Instance member CancelUpload()​

Aborts the current file and pauses remaining files. Upload resumes remaining pending files.

Instance member Clear()​

Aborts any active upload and removes all entries. Application-saved files are not deleted.

Protected member OnFileClick(e)​

Raises FileClick.

ParameterTypeDescription
eDropZoneFileEventArgsMetadata for the activated file.

Protected member OnFileRemoved(e)​

Raises FileRemoved.

ParameterTypeDescription
eDropZoneFileEventArgsFile event data.

Protected member OnFilesAdded(e)​

Raises FilesAdded.

ParameterTypeDescription
eDropZoneFileEventArgsFile event data.

Protected member OnUploadCompleted(e)​

Raises UploadCompleted.

ParameterTypeDescription
eDropZoneFileEventArgsFile event data.

Protected member OnUploadFailed(e)​

Raises UploadFailed.

ParameterTypeDescription
eDropZoneFileEventArgsFile event data.

Protected member OnUploadProgress(e)​

Raises UploadProgress.

ParameterTypeDescription
eDropZoneFileEventArgsFile event data.

Protected member OnValidationFailed(e)​

Raises ValidationFailed.

ParameterTypeDescription
eDropZoneFileEventArgsFile event data.

Protected member OnWebEvent(e)​

Dispatches browser queue events.

ParameterTypeDescription
eWisejEventArgsBrowser event data.

Protected member OnWebRender(config)​

Renders upload settings without replacing the browser queue.

ParameterTypeDescription
configObjectClient configuration.

Instance member Upload()​

Uploads all accepted pending files. This does not open a file dialog.

Events​

Instance member 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})");

Instance member FileRemoved​

EventHandler<DropZoneFileEventArgs> Occurs when the user removes a file from the list.

Instance member FilesAdded​

EventHandler<DropZoneFileEventArgs> Occurs once for each file accepted into the queue.

Instance member UploadCompleted​

EventHandler<DropZoneFileEventArgs> Occurs after server validation of the received file. Read its stream during this event.

Instance member UploadFailed​

EventHandler<DropZoneFileEventArgs> Occurs when an upload fails or is canceled.

Instance member UploadProgress​

EventHandler<DropZoneFileEventArgs> Occurs when the browser reports progress for an accepted file.

Instance member ValidationFailed​

EventHandler<DropZoneFileEventArgs> Occurs when file metadata or the received upload fails validation.

Implements​

NameDescription
IUserDataProvides access to the UserData and Tag properties associated to the component implementing this interface.
IBindableComponentBindable components implement this interface.
IDropTargetControls that support drag & drop operations implement this interface.
IWisejComponentAll wisej components implement this interface.
IWisejControlAll wisej controls derived from the Control class must implement this interface.
IWisejHandlerRepresents a Wisej component that is capable of handling postback requests from the client.
IWisejSerializableAllows an object to serialize itself.