RadUpload
Telerik RadUpload
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
[TelerikToolboxCategory("Upload")]
[ToolboxBitmap(typeof(RadUpload), "Toolbox.Icons.Upload.png")]
[RequiredScript(typeof(Core))]
[RequiredScript(typeof(jQueryPlugins))]
[ClientScriptResource("Telerik.Web.UI.RadUpload", "Telerik.Web.UI.Upload.RadUpload.js")]
[EmbeddedSkin("Upload", typeof(RadUpload))]
[EmbeddedSkin("Upload", "Default", typeof(RadUpload))]
public class RadUpload : RadWebControl, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IScriptControl, IControlResolver, IPostBackDataHandler, ISkinnableControl, IControl
Inheritance: objectControlWebControlRadWebControlRadUpload
Implements:
Inherited Members
Constructors
public RadUpload()
Properties
Gets or sets the allowed file extensions for uploading.
[TypeConverter(typeof(ListConverter))]
[PersistenceMode(PersistenceMode.Attribute)]
[Bindable(true)]
public string[] AllowedFileExtensions { get; set; }
The default value is empty string array. In order to check for multiple file extensions you should set an array of strings containing the allowed file extensions for uploading.
Set this property to empty array of strings in order to prevent the file extension checking.
Note that the file extensions must include the dot before the actual extension. See the example below.
Gets or sets the allowed MIME types for uploading.
[TypeConverter(typeof(ListConverter))]
[PersistenceMode(PersistenceMode.Attribute)]
[Bindable(true)]
public string[] AllowedMimeTypes { get; set; }
The default value is empty string array. In order to check for multiple mime types you should set an array of strings containing the allowed MIME types for uploading.
Set this property to string.Empty in order to prevent the mime type checking.
Gets or sets the value indicating which control objects will be displayed.
[Browsable(true)]
[Bindable(true)]
[ClientControlProperty]
public virtual ControlObjectsVisibility ControlObjectsVisibility { get; set; }
The default value is ControlObjectsVisibility.Default. You can set any combination of the enum values.
ControlObjectVisibility enum members
Member Description None Only the file inputs will be visible. CheckBoxes Display checkboxes for selecting a file input. RemoveButtons Display buttons for removing a file input. ClearButtons Display buttons for clearing a file input. AddButton Display button for adding a file input. DeleteSelectedButton Display button for removing the file inputs with checked checkboxes. Default CheckBoxes | RemoveButtons | AddButton | DeleteSelectedButton All CheckBoxes | RemoveButtons | ClearButtons | AddButton | DeleteSelectedButton
The CssClass property will now be used instead of the former Skin and will be modified in AddAttributesToRender()
protected override string CssClassFormatString { get; }
Overrides:
Gets or sets the selected culture. Localization strings will be loaded based on this value.
public CultureInfo Culture { get; set; }
The culture.
Gets or sets the value indicating whether the file input fields skinning will be enabled.
[Browsable(true)]
[Bindable(true)]
[ClientPropertyName("enableFileInputSkinning")]
[ClientControlProperty]
public bool EnableFileInputSkinning { get; set; }
true when the file input skinning is enabled; otherwise false.
The <input type=file> DHTML elements are not skinnable by default. If the EnableFileInputSkinning is true some browsers can have strange behavior.
Gets or sets the value indicating whether the first file input field of RadUpload should get the focus on itself on load.
[Browsable(true)]
[Bindable(true)]
[ClientPropertyName("focusOnLoad")]
[ClientControlProperty]
public bool FocusOnLoad { get; set; }
true when the first file input field of RadUpload should get the focus; otherwise false. The default value is false.
Gets or sets the initial count of file input fields, which will appear in RadUpload.
[Browsable(true)]
[Bindable(true)]
[ClientPropertyName("initialFileInputsCount")]
[ClientControlProperty]
public int InitialFileInputsCount { get; set; }
The file inputs count which will be available at startup. The default value is 1.
Gets or sets the size of the file input field
[PersistenceMode(PersistenceMode.Attribute)]
[Bindable(true)]
[ClientPropertyName("inputSize")]
[ClientControlProperty]
public int InputSize { get; set; }
The default value is 23.
Provides access to the invalid files uploaded by the RadUpload instance. This is populated only if a validation was set.
[Browsable(false)]
public virtual UploadedFileCollection InvalidFiles { get; }
If the internal validation is enabled this collection contains the invalid uploaded files for the particular instance of RadUpload control.
Gets a value indicating whether the RadUpload HttpModule is registered in the current web.application
[Browsable(false)]
public bool IsUploadModuleRegistered { get; }
Gets or sets the localization language of the RadUpload user interface.
[Browsable(true)]
[Bindable(true)]
[Obsolete("Use the Culture property")]
public string Language { get; set; }
A string containing the localization language of the RadUpload user interface. The default value is en-US.
Gets the localization.
[PersistenceMode(PersistenceMode.InnerProperty)]
public UploadStrings Localization { get; }
The localization.
Gets or sets a value indicating where RadUpload will look for its .resx localization files.
public string LocalizationPath { get; set; }
The localization path.
Gets or sets the maximum file input fields that can be added to the control.
[PersistenceMode(PersistenceMode.Attribute)]
[Bindable(true)]
[ClientPropertyName("maxFileCount")]
[ClientControlProperty]
public int MaxFileInputsCount { get; set; }
The default value is 0 (unlimited).
Using this property you can limit the maximum number of file inputs which can be added to a RadUpload instance.
Gets or sets the maximum file size allowed for uploading in bytes.
[PersistenceMode(PersistenceMode.Attribute)]
[Bindable(true)]
public virtual int MaxFileSize { get; set; }
The default value is 0 (unlimited).
Set this property to 0 in order to prevent the file size checking.
Gets or sets the name of the client-side function which will be executed after a new file input is added to a RadUpload instance.
[Browsable(true)]
[Bindable(true)]
[ClientControlEvent]
[ClientPropertyName("added")]
public string OnClientAdded { get; set; }
The default value is string.Empty.
Gets or sets the name of the client-side function which will be executed before a new file input is added to a RadUpload instance.
[Browsable(true)]
[Bindable(true)]
[ClientControlEvent]
[ClientPropertyName("adding")]
public string OnClientAdding { get; set; }
The default value is string.Empty.
Gets or sets the name of the client-side function which will be executed before a file input field is cleared in a RadUpload instance using the Clear button.
[Browsable(true)]
[Bindable(true)]
[ClientControlEvent]
[ClientPropertyName("clearing")]
public string OnClientClearing { get; set; }
The default value is string.Empty.
Gets or sets the name of the client-side function which will be executed before a file input is deleted from a RadUpload instance.
[Browsable(true)]
[Bindable(true)]
[ClientControlEvent]
[ClientPropertyName("deleting")]
public string OnClientDeleting { get; set; }
The default value is string.Empty.
If you want to cancel the deleting of the file input return false in the javascript handler.
Gets or sets the name of the client-side function which will be executed before the selected file inputs are removed.
[Browsable(true)]
[Bindable(true)]
[ClientControlEvent]
[ClientPropertyName("deletingSelected")]
public string OnClientDeletingSelected { get; set; }
The default value is string.Empty.
You can cancel the removing of the file input items by returning false in the javascript function.
Gets or sets the name of the client-side function which will be executed when a file input value changed.
[Browsable(true)]
[Bindable(true)]
[ClientControlEvent]
[ClientPropertyName("fileSelected")]
public string OnClientFileSelected { get; set; }
The default value is string.Empty.
Gets or sets the value indicating whether RadUpload should overwrite existing files having same name in the TargetFolder.
[Browsable(true)]
[Bindable(true)]
public bool OverwriteExistingFiles { get; set; }
true when the existing files should be overwritten; otherwise false. The default value is false.
When set to true, the existing files are overwritten, else no action is taken.
Gets or sets a value indicating if the file input fields should be read-only (e.g. no typing allowed).
[Browsable(true)]
[Bindable(true)]
public bool ReadOnlyFileInputs { get; set; }
true when the file input fields should be read-only; otherwise false.
When users type into the box and the filename is not valid, the form submission in Internet Explorer could not proceed or even display a javascript error. This behavior can be avoided by setting the ReadOnlyFileInputs property to true.
protected override HtmlTextWriterTag TagKey { get; }
Overrides:
Gets or sets the virtual path of the folder, where RadUpload will automatically save the valid files after the upload completes.
[Browsable(true)]
[Bindable(true)]
public string TargetFolder { get; set; }
A string containing the virtual path of the folder where RadUpload will automatically save the valid files after the upload completes. The default value is string.Empty.
When set to string.Empty, the files must be saved manually to the desired location.
If both TargetPhysicalFolder property and this property are set, the TargetPhysicalFolder will override the virtual path provided by TargetFolder.
Gets or sets the physical path of the folder, where RadUpload will automatically save the valid files after the upload completes.
[Browsable(true)]
[Bindable(true)]
public string TargetPhysicalFolder { get; set; }
A string containing the physical path of the folder where RadUpload will automatically save the valid files after the upload completes. The default value is string.Empty.
When set to string.Empty, the files must be saved manually to the desired location.
If both TargetFolder property and this property are set, the TargetPhysicalFolder will override the virtual path provided by TargetFolder.
Provides access to the valid files uploaded by the RadUpload instance.
[Browsable(false)]
public UploadedFileCollection UploadedFiles { get; }
UploadedFileCollection containing all valid files uploaded using a RadUpload control.
The collection contains only the files uploaded with the particular instance of the RadUpload control. If the RadUploadHttpModule is used, the uploaded files are removed from the Request.Files collection in order to conserve the server's memory. Else the Request.Files contains all uploaded files as a HttpPostedFile collection and each RadUpload instance has its own uploaded files as UploadedFileCollection.
Methods
protected override void AddAttributesToRender(HtmlTextWriter writer)
Overrides:
protected override void DescribeComponent(IScriptDescriptor descriptor)
Overrides:
protected bool IsValidUploadedFile(UploadedFile file, bool checkingFileSize, bool checkingFileExtension, bool checkingMimeType)
Executed when post data is loaded from the request
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
Overrides:
Fires the FileExists event.
Fires the ValidatingFile event.
protected virtual bool OnValidatingFile(ValidateFileEventArgs e)
protected virtual void PopulateUploadedFiles()
protected virtual void ProcessValidFiles()
protected override void RenderContents(HtmlTextWriter writer)
Overrides:
protected virtual void ValidateUploadedFiles()
Events
Occurs after an unsuccessful attempt for automatic saving of a file in the UploadedFiles collection.
public event UploadedFileEventHandler FileExists
This event should be consumed only when the automatic file saving is enabled by setting the TargetFolder property. In this mode the files are saved in the selected folder with the same name as on the client computer. If a file with such name already exists in the TargetFolder it is either overwritten or skipped depending the value of the OverwriteExistingFiles property. This event is fired if OverwriteExistingFiles is set to false and a file with the same name already exists in the TargetFolder.
Occurs before the internal validation of every file in the UploadedFiles collection.
public event ValidateFileEventHandler ValidatingFile
To skip the internal validation of the file, set e.SkipInternalValidation = true.