This is a migrated thread and some comments may be shown as answers.
Event Property Documentation
2 Answers 42 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fred Chateau
Top achievements
Rank 1
Fred Chateau asked on 30 Nov 2011, 01:55 AM
I cannot seem to find documentation on the properties of events in the Upload control. There is a rich assortment of events associated with the control, but no information on any of their properties.

I want to be able to provide a better success/error response to uploads than the examples provided in the documentation, by returning custom error messages in JSON, but the only property referenced that I could find was for OnSuccess -- e.response.status, which didn't seem to work.

I tried the following guesses for OnError but none of them worked either -- e.error, e.errormsg, e.response.error, e.response.errormsg, and e.response.status. They all returned undefined in error situations.

The documentation says to return an empty string on success, and that seems to be the only thing that doesn't generate an undefined response.

Also, I'm uploading asynchronously, using the AutoUpload = false setting. When I do that, there is no progress meter shown, like there is with AutoUpload = true. In the former case, an animation image shows, followed by a green dot on success, or a red dot on error. Is there a way to get the progress meter to show on manual uploads. (I am not referring to synchronous uploads, just manual asynchronous ones.)

2 Answers, 1 is accepted

Sort by
0
Fred Chateau
Top achievements
Rank 1
answered on 30 Nov 2011, 02:55 AM

To further elaborate on the previous post:

Our files are not simply saved on the hard drive. They are changed into a memory stream and further processed. We want to inform the user what occurred if something were to go wrong with that processing. For example:

catch (Exception ex)
{
    return new FileUploadJsonResult { Data = new { message = ex.message } };
}

I assume this message will return from the server as an HTTP Status 200, so the proper way to handle it would be the Upload control's OnSuccess event.

Alternatively, it may be possible for us to return some error information using the HTTP status codes.

catch (HttpException ex)
{
    HttpContext.Response.StatusCode = ex.GetHtmlFromError();
    return String.Empty;
}

This, I assume, would pass the error through the Upload control's OnError event.

Am I on the right track here. Are there appropriate properties included with these events to handle the errors?
0
T. Tsonev
Telerik team
answered on 02 Dec 2011, 03:21 PM
Hi Fred,

The Upload requires any JSON response to be transferred with "text/plain" encoding because of browser limitations. The response is then accessible in the OnSuccess event. The OnError event won't be fired.

Please consult the Sending and receiving metadata help topic for more details.

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
Tags
Upload
Asked by
Fred Chateau
Top achievements
Rank 1
Answers by
Fred Chateau
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or