Table of Contents

Class RadzenUpload

Namespace
Radzen.Blazor
Assembly
Radzen.Blazor.dll

RadzenUpload component.

public class RadzenUpload : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Inheritance
RadzenUpload
Implements
Inherited Members

Examples

<RadzenUpload Url="upload/single" Progress=@(args => OnProgress(args, "Single file upload"))/>
@code {
 void OnProgress(UploadProgressArgs args, string name)
 {
   this.info = $"% '{name}' / {args.Loaded} of {args.Total} bytes.";
   this.progress = args.Progress;
   if (args.Progress == 100)
   {
       console.Clear();

       foreach (var file in args.Files)
       {
           console.Log($"Uploaded: {file.Name} / {file.Size} bytes");
       }
   }
 }
}

Constructors

RadzenUpload()

public RadzenUpload()

Fields

fileUpload

Gets file input reference.

protected ElementReference fileUpload

Field Value

ElementReference

Properties

Accept

Gets or sets the accepted MIME types.

[Parameter]
public string Accept { get; set; }

Property Value

string

The accepted MIME types.

Auto

Gets or sets a value indicating whether this RadzenUpload upload is automatic.

[Parameter]
public bool Auto { get; set; }

Property Value

bool

true if upload automatic; otherwise, false.

Change

Gets or sets the change callback.

[Parameter]
public EventCallback<UploadChangeEventArgs> Change { get; set; }

Property Value

EventCallback<UploadChangeEventArgs>

The change callback.

ChildContent

Gets or sets the child content.

[Parameter]
public RenderFragment ChildContent { get; set; }

Property Value

RenderFragment

The child content.

ChooseText

Gets or sets the choose button text.

[Parameter]
public string ChooseText { get; set; }

Property Value

string

The choose button text.

Complete

Gets or sets the complete callback.

[Parameter]
public EventCallback<UploadCompleteEventArgs> Complete { get; set; }

Property Value

EventCallback<UploadCompleteEventArgs>

The complete callback.

DeleteText

Gets or sets the choose button text.

[Parameter]
public string DeleteText { get; set; }

Property Value

string

The choose button text.

Disabled

Gets or sets a value indicating whether this RadzenUpload is disabled.

[Parameter]
public bool Disabled { get; set; }

Property Value

bool

true if disabled; otherwise, false.

Error

Gets or sets the error callback.

[Parameter]
public EventCallback<UploadErrorEventArgs> Error { get; set; }

Property Value

EventCallback<UploadErrorEventArgs>

The error callback.

HasValue

Gets a value indicating whether this instance has value.

public bool HasValue { get; }

Property Value

bool

true if this instance has value; otherwise, false.

Icon

Gets or sets the icon.

[Parameter]
public string Icon { get; set; }

Property Value

string

The icon.

IconColor

Gets or sets the icon color.

[Parameter]
public string IconColor { get; set; }

Property Value

string

The icon color.

ImageAlternateText

Gets or sets the text.

[Parameter]
public string ImageAlternateText { get; set; }

Property Value

string

The text.

InputAttributes

Specifies additional custom attributes that will be rendered by the input.

[Parameter]
public IReadOnlyDictionary<string, object> InputAttributes { get; set; }

Property Value

IReadOnlyDictionary<string, object>

The attributes.

MaxFileCount

Gets or sets the maximum number of files.

[Parameter]
public int MaxFileCount { get; set; }

Property Value

int

The maximum number of files.

Multiple

Gets or sets a value indicating whether this RadzenUpload is multiple.

[Parameter]
public bool Multiple { get; set; }

Property Value

bool

true if multiple; otherwise, false.

Name

Gets or sets the name.

[Parameter]
public string Name { get; set; }

Property Value

string

The name.

ParameterName

Gets or sets the parameter name. If not set 'file' parameter name will be used for single file and 'files' for multiple files.

[Parameter]
public string ParameterName { get; set; }

Property Value

string

The parameter name.

Progress

Gets or sets the progress callback.

[Parameter]
public EventCallback<UploadProgressArgs> Progress { get; set; }

Property Value

EventCallback<UploadProgressArgs>

The progress callback.

Url

Gets or sets the URL.

[Parameter]
public string Url { get; set; }

Property Value

string

The URL.

Methods

BuildRenderTree(RenderTreeBuilder)

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

ClearFiles()

Clear selected file(s) from the upload selection

public Task ClearFiles()

Returns

Task

GetComponentCssClass()

protected override string GetComponentCssClass()

Returns

string

GetHeaders()

Gets the headers.

[JSInvokable("GetHeaders")]
public IDictionary<string, string> GetHeaders()

Returns

IDictionary<string, string>

IDictionary<System.String, System.String>.

OnAfterRenderAsync(bool)

protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

Returns

Task

OnChange(IEnumerable<PreviewFileInfo>)

Called on file change.

[JSInvokable("RadzenUpload.OnChange")]
public Task OnChange(IEnumerable<PreviewFileInfo> files)

Parameters

files IEnumerable<PreviewFileInfo>

The files.

Returns

Task

OnComplete(string, bool)

Called when upload is complete.

[JSInvokable("RadzenUpload.OnComplete")]
public Task OnComplete(string response, bool cancelled)

Parameters

response string

The response.

cancelled bool

Flag indicating if the upload was cancelled

Returns

Task

OnError(string)

Called on upload error.

[JSInvokable("RadzenUpload.OnError")]
public Task OnError(string error)

Parameters

error string

The error.

Returns

Task

OnProgress(int, long, long, IEnumerable<FileInfo>, bool)

Called on progress.

[JSInvokable("RadzenUpload.OnProgress")]
public Task<bool> OnProgress(int progress, long loaded, long total, IEnumerable<FileInfo> files, bool cancel)

Parameters

progress int

The progress.

loaded long

The loaded.

total long

The total.

files IEnumerable<FileInfo>

The files.

cancel bool

The cancelled state.

Returns

Task<bool>

OnRemove(PreviewFileInfo, bool)

Called on file remove.

protected Task OnRemove(PreviewFileInfo file, bool fireChangeEvent = true)

Parameters

file PreviewFileInfo

The file.

fireChangeEvent bool

If the linked Change event should be fired as a result of this removal (default: true)

Returns

Task

RemoveFile(string, bool)

Called on file remove.

public Task RemoveFile(string fileName, bool ignoreCase = false)

Parameters

fileName string

The name of the file to remove.

ignoreCase bool

Specify true is file name casing should be ignored (default: false)

Returns

Task

SetParametersAsync(ParameterView)

public override Task SetParametersAsync(ParameterView parameters)

Parameters

parameters ParameterView

Returns

Task

Upload()

Uploads this instance selected files.

public Task Upload()

Returns

Task