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

RadAsyncUpload and client side Validation sometimes fails???

1 Answer 204 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 2
Gary asked on 11 Jul 2011, 08:26 PM

Hello,

 I have a question I hope someone has an answer for.

 

I have a custom control that includes  the RadAsyncUpload control.  In the onInit event handler calculate a MaxFileSize based on a config file setting and then register a couple of scripts to handle the error display if the file being uploaded exceeds the MaxFileSize:

 i.e

             StringBuilder sb = new StringBuilder();

             sb.Append("\n\t<script type=\"text/javascript\">\n\t\tfunction UploadValidationError(sender, eventArgs)\n\t\t{\n\t\t\talert('")

              .Append(AlertText1)
              .Append(": ' + eventArgs.get_fileName() + ' ")
              .Append(AlertText2).Append(" ")
              .Append(MaxFileSize.ToString())
              .Append(" kb.\');\n\t\t}\n\t</script>");

             Page.Header.Controls.Add(new LiteralControl(sb.ToString()));               

 

            StringBuilder sb2 = new StringBuilder();

             sb2.Append("\n\t<script type=\"text/javascript\">\n\t\tfunction FileUploadError(sender, eventArgs)\n\t\t{\n\t\t\talert('")
               .Append(AlertText3)
               .Append(" ' +  eventArgs.get_message() );\n\t\t}\n\t</script>");

              Page.Header.Controls.Add(new LiteralControl(sb2.ToString()));

 Then when the RadAsyncUpload control is being added to the

            public Telerik.Web.UI.RadAsyncUpload _uploadControl = new Telerik.Web.UI.RadAsyncUpload();

  

                this._uploadControl.ID = "u" + this.QuestionID;

                this._uploadControl.InitialFileInputsCount = 1;
                this._uploadControl.MaxFileInputsCount = 1;
                this._uploadControl.MaxFileSize = MaxFileSize;
                this._uploadControl.FileUploaded += new FileUploadedEventHandler(File_FileUploaded);
                this._uploadControl.TemporaryFolder = _fileVirtualPath;
                this._uploadControl.TargetFolder =_fileVirtualPath ;
                this._uploadControl.HttpHandlerUrl = "~/RadUpload/RadUploadFile.ashx";
                this._uploadControl.Width = new Unit(250);
                this._uploadControl.CssClass = "normalRemoveButton";
                this._uploadControl.OnClientValidationFailed = "UploadValidationError";
                this._uploadControl.OnClientFileUploadFailed = "FileUploadError"; 
                this._uploadControl.Style.Add("display", "block");   
                this._uploadLabel.Text = NoFileSelectedText;
                this._uploadLabel.Enabled = false;
                this._uploadControl.Culture = new System.Globalization.CultureInfo(CultureCode);

This all works flawlessly on most browsers, select a file too large and the alert box pops up indicating that the filesize exceeds the limit.  However on some testers machines, when they select a file to upload that is way too large , the yellow uploading line activates, the alert box does not show, and it continues in that state for several minutes if you let it.

 

 (I am not even sure that it is browser related, it may be individual machines and the browser configutration).  It does not seem to be version specific, we have tried this under IE7, IE8, and IE9.

 
Any ideas?

 
Thanks,
Gary

 

1 Answer, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 13 Jul 2011, 05:16 PM
Hello Gary,

Please check which module are you using when the RadAsyncUpload hangs up (right button click on the file input).
When the IFrame module is used the file is uploaded to the server and if it is larger than the MaxFileSize property an exception is thrown. Please increase the values of the maxRequestLength and maxAllowedContentLength properties.

Best wishes,
Peter Filipov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
AsyncUpload
Asked by
Gary
Top achievements
Rank 2
Answers by
Peter Filipov
Telerik team
Share this question
or