This is a migrated thread and some comments may be shown as answers.

[Solved] Populating an input based on upload controls

1 Answer 17 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Werner
Top achievements
Rank 1
Werner asked on 06 Oct 2011, 12:29 AM
Hello,

I have a page that has an input (with id Title) and two upload controls.  The reason two exists is because I need to differentiate between an original and modified document.  A single upload control doesn't allow this differentiation.  Multiple uploads per upload control is not allowed.

I have a requirement to populate the title input field with the file names of the upload controls.  To achieve that, each control looks as follows (replace Orignal with Modified for the other control):

<%= Html.Telerik().Upload()
        .Name("OriginalDocument")
        .ShowFileList(true)
        .Multiple(false)
        .Async(async => async
            .Save("SaveOriginal", "Comparisons")
            .Remove("RemoveOriginal", "Comparisons")
            .AutoUpload(true)
        )
        .ClientEvents(events => events
            .OnError("onUploadError")
            .OnSuccess("onUploadSuccess")
        )
        
%>

The upload success looks as follows:

function onUploadSuccess(e) {
    var originalUpload = $("#OriginalDocument").data("tUpload");
    var modifiedUpload = $("#ModifiedDocument").data("tUpload");
    // What do I do here??
}

How can I extract the file names from originalUpload and modifiedUpload? 

Thanks,
Werner

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 10 Oct 2011, 03:02 PM
Hello Werner,

The OnSuccess event arguments contain a list of the uploaded files. The name can be extracted from there:

function onOriginalUploadSuccess(e) {
    var originalFile = e.files[0].name;
    // ...
}

I hope this helps.

Regards,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Upload
Asked by
Werner
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or