AUTHOR: Peter Milchev
DATE POSTED: April 02, 2018
Files are not available in the OnClientFileSelected event of the RadAsyncUpload.
Having the files available in the arguments of the event could be useful when the file is needed for some processing on the client before uploading. Few examples are:
Overriding the private _onFileSelected function to pass the file would make it accessible in the OnClientFileSelected event handler via args.get_file() method.
Placing the following workaround below the ScriptManager should enable the file access via the arguments:
var
$ = $ || $telerik.$;
Telerik.Web.UI.RadAsyncUpload.prototype._onFileSelected =
function
(row, fileInput, fileName, shouldAddNewInput, file) {
args = {
row: row,
fileInputField: fileInput,
file: file
};
args.rowIndex = $(row).index();
args.fileName = fileName;
this
._selectedFilesCount++;
shouldAddNewInput = shouldAddNewInput &&
(
.get_maxFileCount() == 0 ||
._selectedFilesCount <
.get_maxFileCount());
._marshalUpload(row, fileName, shouldAddNewInput);
labels = $(
"label"
, row);
if
(labels.length > 0)
labels.remove();
$.raiseControlEvent(
,
"fileSelected"
, args);
}
Then, in the OnClientFileSelected event, the file should be accessible as follows:
<
telerik:RadAsyncUpload
runat
=
"server"
ID
"RadAsyncUpload1"
OnClientFileSelected
"OnClientFileSelected"
/>
<script>
OnClientFileSelected(sender, args) {
file = args.get_file();
(file) {
// use the file
</script>
Resources Buy Try