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

[Solved] Save event and new {} parameter

4 Answers 93 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.
Louis
Top achievements
Rank 1
Iron
Iron
Iron
Louis asked on 08 Dec 2011, 02:18 AM
Hello,

I upload a file and after the call to the server, I have a small JavaScript that update Model.ImageName on client side.

But when I Upload again,  Model.Image always keep the fisrt value (in .Save... new...). 

I change the new with this new { strImageName = Model.ImageName, test = System.DateTime.Now } to see if the time change but it's keep the first value when I upload for the first time.  Any idea will be VERY APPRECIATE.
@(Html.Telerik().Upload().Name("attachments").Multiple(false).ShowFileList(false)
            .Async(async => async                   
                .Save("Save", "Description", new { strImageName = Model.ImageName })
            .AutoUpload(true))
            .ClientEvents(events => events.OnSuccess("onSuccess")  .OnUpload("onUpload"))
            )




4 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 08 Dec 2011, 06:31 PM
Hello Louis,

You need to set the image name on the client, using the upload event. Please consult the Sending and receiving metadata help article for detailed instructions.

I hope this helps.

Kind 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
0
Louis
Top achievements
Rank 1
Iron
Iron
Iron
answered on 09 Dec 2011, 12:15 AM
Hello Tsvetomir,

In fact, I alread use Upload event and I update my Model.ImageName  But it'seem  the new { strImageName = Model.ImageName }) is not udpated because it's an Ajax part I think.

Any suggestion?
0
T. Tsonev
Telerik team
answered on 09 Dec 2011, 03:37 PM
Hello Louis,

The route parameters set in the Save action configuration are used to build a URL like /Save&strImageName=image. It remains static from then on.

The upload event can be used to add route parameters dynamically, as part of the POST request to the Save action:

function onUpload(e) {
    e.data = { strImageName: newImageName };
}

If you're using the upload event you can skip the static configuration altogether:
.Save("Save", "Description")

I hope this helps.

Greetings,
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
0
Louis
Top achievements
Rank 1
Iron
Iron
Iron
answered on 10 Dec 2011, 12:35 AM
Dearest Tsvetomir,

BIG THANK YOU to YOU,  It's work like a charm!!!

function onUpload(e) {
    // Array with information about the uploaded files
    var files = e.files;
 
    // Check the extension of each file and abort the upload if it is not .jpg
    $.each(files, function () {
        if (this.extension.toLowerCase() != ".jpg" && this.extension.toLowerCase() != ".png" && this.extension.toLowerCase() && ".jpeg" && this.extension.toLowerCase() != ".gif") {
            alert("Tsssssssssssssssssssssssss")
            e.preventDefault();
            return false;
        }
    });
    e.data = { strImageName: document.getElementById('tblDescription_GeneralImage').value };
}


Have a NICE week-end!!
Tags
Upload
Asked by
Louis
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
T. Tsonev
Telerik team
Louis
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or