Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to upload image files using html editor extender. Everything works fine so far and I am able to save the file on ImageUploadComplete event. But I am not sure how to raise the error to UI and alert user if the image upload fails for some reason.

Your help would be very much appreciated. Thanks!

Update: We use MS enterprise library for exception handling. In normal postback errors, the exception gets logged first and would get redirected to the custom error page. The issues with using HTMLEditorExtender are:

  1. redirect on error is NOT working
  2. fileupload control is showing wrong upload status - "Uploaded" even in case of failures.

    Public Sub HTMLEditor_ImageUploadComplete(sender As Object, e As AjaxControlToolkit.AjaxFileUploadEventArgs) Handles HTMLEditor.ImageUploadComplete

    HTMLEditor.AjaxFileUpload.SaveAs("D:\Uploads\" + Path.GetFileName(e.FileName))

    End Sub

share|improve this question
Do you want to do it via code-behind or client side? And could you show us the code you have so far? – Garrison Neely Jul 17 at 20:29
I am able to catch the error in code behind using try catch block, but the issue is I am not able to redirect to the error page or show the correct status in the file upload control. Thanks. – Jisha Mathew Jul 18 at 19:04

1 Answer

Since this is a server-side control you should be able to report errors like you would server-side for anything else (i.e. ASP.NET Label control with red forecolor and invisible until an error occurs), like this:

<asp:Label id="ErrorLabel" runat="server" ForeColor="Red" Visible="False"/>

Then on the method referenced in your OnImageUploadComplete attribute of the extender control you can direct error information to this error label control.

share|improve this answer
I tried using the label control and changing the control text/visibility on error. Unfortunately none of the changes gets displayed on the UI, since the editor is an ajax control and there is no page refresh on error. Thanks. – Jisha Mathew Jul 18 at 19:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.