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

Upload Client Events firing on Page Load

3 Answers 44 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.
Christopher
Top achievements
Rank 1
Christopher asked on 01 Nov 2011, 09:13 PM
I'm attempting to determine why the OnComplete Client Event is not firing in my main application. Due to the nature of my work, I cannot share my code, so I created a sample project with the Telerik Upload and Grid controls and the client events are firing both on page load and upon returning from the controller. In my main application, the client events only fire on page load and not upon returning from the controller. I have attached my sample app to see if anyone can see why they are firing on page load.

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 03 Nov 2011, 09:18 AM
Hi Christopher,

The OnComplete event seems to fire normally in the test project. Not sure if I'm missing something.

By the way, have you looked at the Upload in Grid code library? It can give you some ideas on integrating them.

All the best,
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
Alex
Top achievements
Rank 1
answered on 04 Nov 2011, 03:03 PM
I think I can help you with this cause it happened to me too when I first used the uploader. I just put an alert into the select event to see it trigger. It looked like this:

Html.Telerik().Upload()
                        .Name("attachments")
                        .Multiple(true)                        
                        .Async(s=>s.Save("UploadFiles","Home")
                                   .Remove("RemoveFiles", "Home")
                        )
                        .ClientEvents(e => e.OnSelect("alert('test')").OnComplete("alert('test2')"))

What happened was that every time the page loaded I got both alerts like the events were somehow triggered and after that they stopped working entirely. By luck and after some frustration I changed it to what you see below and everything started working the way it should have.

<script>
    function test() {
        alert("test");
    }

function test2() {
        alert("test");
    }
</script>

Html.Telerik().Upload()
                        .Name("attachments")
                        .Multiple(true)                        
                        .Async(s=>s.Save("UploadFiles","Home")
                                   .Remove("RemoveFiles", "Home")
                        )
                        .ClientEvents(e => e.OnSelect("test").OnComplete("test2"))
0
Patrick
Top achievements
Rank 1
answered on 22 Nov 2011, 04:38 PM
I did the same but it seems not to work.
<script type="text/javascript">
    function onSuccess() {         alert("test");     }
</script>
@(Html.Telerik().Upload()
        .Name("attachments")
        .Multiple(true)
        .Async(s => s.Save("Upload""Attachment").AutoUpload(true))
        .ClientEvents(e => e.OnSelect("onSuccess").OnSuccess("onSuccess"))
)

It does upload the file, but it does never ever fire the test alert. When I implement the previous example it is firing all events on page load. Could this be a problem in the 2011.2.712 version?
Tags
Upload
Asked by
Christopher
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Alex
Top achievements
Rank 1
Patrick
Top achievements
Rank 1
Share this question
or