New to Telerik UI for ASP.NET MVC? Start a free 30-day trial

Defines the fluent interface for configuring the Upload component.

Definition

Constructors

Initializes a new instance of the UploadBuilder class.

C#
public UploadBuilder(Upload component)
Parameters:componentUpload

The component.

Methods

Use it to configure asynchronous uploading.

C#
public UploadBuilder Async(Action<UploadAsyncSettingsBuilder> configurator)
Parameters:configuratorAction<UploadAsyncSettingsBuilder>

Use builder to set different asynchronous uploading options.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.Async(async =&gt; async
.Save("Save", "Home")
.Remove("Remove", "Home")
)
)

Enables selection of folders instead of files. When a directory is selected, its entire hierarchy of contents files is included in the set of selected items. It is only supported in browsers that support webkitdirectory.

C#
public UploadBuilder Directory(bool value)
Parameters:valuebool

true allows directory upload.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.Directory(true)
)

Enables dropping folders over the upload and its drop zone. When a directory is dropped, its entire hierarchy of contents files is included in the set of selected items. It is only supported in browsers that support DataTransferItem and webkitGetAsEntry.

C#
public UploadBuilder DirectoryDrop(bool value)
Parameters:valuebool

true allows directory drop.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.DirectoryDrop(true)
)

The string jQuery selector for the DropZone

C#
public UploadBuilder DropZone(string dropZone)
Parameters:dropZonestring

The string jQuery selector for the DropZone

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.DropZone("DropZone")
.Async(async =&gt; async
.Save("Save", "Home")
.Remove("Remove", "Home")
)
)

Enables or disables the component.

C#
public UploadBuilder Enable(bool value)
Parameters:valuebool

true if the component should be enabled, false otherwise; the default is true.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.Enable(false)
)

Configures the client-side events.

C#
public UploadBuilder Events(Action<UploadEventBuilder> configurator)
Parameters:configuratorAction<UploadEventBuilder>

The client events configuration action.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.Events(events =&gt; events
.Upload("onUpload")
)
)

Sets the initially rendered files. This option is available only when the Upload is in asynchronous mode. As a result, the files are displayed as uploaded successfully.

C#
public UploadBuilder Files(Action<UploadFileFactory> configurator)
Parameters:configuratorAction<UploadFileFactory>

The lambda which configures initial files

Returns:

UploadBuilder

Example:
C#
@(Html.Kendo().Upload()
.Name("files")
.Files(files =&gt; files.Add().Name("file.txt").Size(500).Extension(".txt"))
.Async(a =&gt; a
.Save("Save", "Compose")
.Remove("Remove", "Compose")
.AutoUpload(true)
)
)

Use it to configure asynchronous uploading.

C#
public UploadBuilder Messages(Action<UploadMessagesBuilder> configurator)
Parameters:configuratorAction<UploadMessagesBuilder>

Use builder to set different asynchronous uploading options.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.Async(async =&gt; async
.Save("Save", "Home")
.Remove("Remove", "Home")
)
)

Enables or disables multiple file selection.

C#
public UploadBuilder Multiple(bool value)
Parameters:valuebool

true if multiple file selection should be enabled, false otherwise; the default is true.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.Multiple(false)
)

Sets a value indicating whether to show the list of uploaded files

C#
public UploadBuilder ShowFileList(bool value)
Parameters:valuebool

true if the list of uploaded files should be visible, false otherwise; true by default

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.ShowFileList(false)
)

Defines a template for rendering the files in the file list.

C#
public UploadBuilder Template<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

The JavaScript function that will return the template content.

Returns:

UploadBuilder

Example:
C#
@(Html.Kendo().Upload()
.Name("Upload")
.Template(Html.Kendo().Template().AddHtml("&lt;div class='file-wrapper'&gt;&lt;h4 class='file-heading file-name-heading'&gt;Name: ${data.name}&lt;/h4&gt;&lt;/div&gt;"))
.Async(async =&gt; async
.Save("Save", "Home")
.Remove("Remove", "Home")
)
)

Defines a template for rendering the files in the file list.

C#
public UploadBuilder TemplateHandler(string template)
Parameters:templatestring

The JavaScript function that will return the template content.

Returns:

UploadBuilder

Example:
C#
@(Html.Kendo().Upload()
.Name("Upload")
.TemplateHandler("fileTemplate")
.Async(async =&gt; async
.Save("Save", "Home")
.Remove("Remove", "Home")
)
)

Defines a template for rendering the files in the file list.

C#
public UploadBuilder TemplateId(string templateId)
Parameters:templateIdstring

The "id" attribute of the external Kendo UI Template.

Returns:

UploadBuilder

Example:
C#
@(Html.Kendo().Upload()
.Name("Upload")
.TemplateId("fileTemplate")
.Async(async =&gt; async
.Save("Save", "Home")
.Remove("Remove", "Home")
)
)

Defines a template for rendering the files in the file list.

C#
public UploadBuilder TemplateView(MvcHtmlString template)
Parameters:templateMvcHtmlString

The Razor View that contains the file template.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.TemplateView(Html.Partial("TemplateView"))
.Async(async =&gt; async
.Save("Save", "Compose")
.Remove("Remove", "Compose")
)
)

Use it to configure validation.

C#
public UploadBuilder Validation(Action<UploadValidationSettingsBuilder> configurator)
Parameters:configuratorAction<UploadValidationSettingsBuilder>

Use builder to set different validation options.

Returns:

UploadBuilder

Example:
C#
@( Html.Kendo().Upload()
.Name("Upload")
.Validation(async =&gt; async
.MaxFileSize(900000)
)
)