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

Handle HTTP Errors

3 Answers 55 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Torben
Top achievements
Rank 1
Torben asked on 15 Mar 2013, 02:15 PM
Hello Forum,
we are using the RadAsyncUpload for an ImageUpload.
I am currently working on the user friendliness of our application.
When i change the name of for example a Message-File from "MyMessage.msg" to "MyMessage.png" it will pass through the validation but the Visual Studio shows a exception. For the user however its just like everything went well.
Except it leads to problems later because the uploaded file is not really an Image...

Is there any way to catch this error, so i can show an alert to the user?

3 Answers, 1 is accepted

Sort by
0
MasterChiefMasterChef
Top achievements
Rank 2
answered on 15 Mar 2013, 06:07 PM
Hi Torben,

Hopefully Telerik does something internally to make sure that this name change will not pass validation. In the meantime, you can use two of the client-side events to make sure that the name wasn't changed by the user. You could use the OnClientFileSelected event to get the current file name (get_fileName parameter), and then after the OnClientFileUploading event fires you could compare the uploading file name with the selected file name. 

Hopefully this helps,
Master Chief
0
Plamen
Telerik team
answered on 19 Mar 2013, 12:43 PM
Hello Torben,

 
 I have inspected the issue and when setting the AllowedFilesExtensions property as for example in this on-line demo after changing the extension of the file it was validated properly. You can then use the OnClientValidationFailed event as shown in this article.

If your scenario is some how different please elaborate a little bit so we could be more helpful.

Regards,
Plamen
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Torben
Top achievements
Rank 1
answered on 19 Mar 2013, 01:07 PM
Thanks for your replys.
The soluition im using now is as following:
When the file is uploaded and i get to my Upload Handler i convert the file into an Image.
So if the Validation suceeded but the File isn't an image the convewrsion will fail and a exception is thrown.
The the Upload fails and i get into the OnFileUploadFailed method, where i can show the Error.
Tags
AsyncUpload
Asked by
Torben
Top achievements
Rank 1
Answers by
MasterChiefMasterChef
Top achievements
Rank 2
Plamen
Telerik team
Torben
Top achievements
Rank 1
Share this question
or