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

Client-side size check error

4 Answers 98 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Brad Docimo
Top achievements
Rank 1
Brad Docimo asked on 20 Aug 2008, 04:21 AM
I am running the following example--no modifications--and it doesn't seem to work correctly:
http://www.telerik.com/help/aspnet-ajax/upload_clientsideonclientprogressupdating.html


When I upload small files, they upload fine, but files that exceed the limit are let through as well, and thus fail on postback.

Any suggestions?

Thanks

4 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 20 Aug 2008, 06:25 AM
Hello Brad,

Please refer to this help article for details on how to validate the file size on the client.

Sincerely yours,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Brad Docimo
Top achievements
Rank 1
answered on 20 Aug 2008, 01:08 PM
Thanks for the new link, but the script on that page is an exact copy of the one I used.  Any more suggestions?  I'm running the script completely unmodified, so it should be relatively easy to replicate:

Latest release of RadControls (Q2-08), ASP.net 2.0 site, RadUpload with a ProgressTemplate

Occasionally, I'm also receiving the following javaScript error, but not every time:
'get_drogressData().RadUpload.RequestSize' is null or not an object

Thanks,

- Brad
0
Brad Docimo
Top achievements
Rank 1
answered on 20 Aug 2008, 02:30 PM
Maybe it's just me, but I can't seem to get any client-side events to work.  I'm going to post my code.  Hopefully, that will help.

Two errors:
- The size check doesn't work, and gives a variety of errors as listed above
- The cancel button says 'Object does not support this method' when clicked

        <script type="text/javascript">  
             function onClientProgressBarUpdating(progressArea, args)  
             {  
               progressArea.updateHorizontalProgressBar(args.get_progressBarElement(), args.get_progressValue());  
               args.set_cancel(true);  
             }  
             function checkUploadedFilesSize(progressArea, args)  
             {  
               //progressArea.confirmed is a custom variable,  
               // you can use another if you want to  
               if (!progressArea.confirmed &&  
                   args.get_progressData().RadUpload.RequestSize > 1000000)  
               {  
                 if (confirm("The total size of the selected files" +  
                             " is more than the limit." +  
                             " Do you want to cancel the upload?"))  
                 {  
                    progressArea.cancelRequest();  
                 }  
                 else 
                 {  
                    progressArea.confirmed = "confirmed";  
                 }  
               }  
             }  
             function cancelUpload()  
             {  
               RadProgressArea1.cancelRequest();  
             }  
        </script> 
        <telerik:RadProgressManager ID="RadProgressManager1" runat="server" />  
        <table cellpadding="0" cellspacing="0" border="0">  
            <tr>  
                <td>  
                    <div id="divUploadPanel" style="width: 220px; height: 30px; overflow: hidden;">  
                        <telerik:RadUpload ID="RadUpload1" runat="server" ControlObjectsVisibility="None" InitialFileInputsCount="1" Skin="LightGreen" EnableEmbeddedSkins="False" />  
                    </div>  
                </td>  
                <td valign="middle" style="padding-top: 1px; padding-right: 10px;">  
                    <asp:LinkButton ID="btnUpload" CssClass="LinkButton" Height="19" runat="server">Upload File</asp:LinkButton>  
                </td>  
                <td style="padding-top: 5px;">  
                    <div id="divProgressPanel" style="width: 283px; height: 30px; overflow: hidden;">  
                        <telerik:RadProgressArea   
                          ID="RadProgressArea1"   
                          runat="server" 
                          OnClientProgressBarUpdating="onClientProgressBarUpdating" 
                          OnClientProgressUpdating ="checkUploadedFilesSize">  
                             <ProgressTemplate>  
                                <div style="background-image: url('/Intranet%20Local%20Copy/doc/images/interface-v2/BG-UploadBar-Off.gif');
                                            background-repeat: repeat-x;
                                            position: relative; 
                                            border: solid 1px #9A9A87; 
                                            height: 12px; 
                                            width: 200px;">  
                                   <div id="PrimaryProgressBarInnerDiv" 
                                     runat="server" 
                                     style="background-image: url('/Intranet%20Local%20Copy/doc/images/interface-v2/BG-UploadBar-On.gif');
                                            background-position: right top;
                                            background-color: #EAEADB; 
                                            height: 10px; 
                                            width: 100%;
                                            vertical-align: top; 
                                            position: relative;
                                            top: 1px;
                                            left: 0px; 
                                            z-index: 900;">  
                                            <!-- / -->  
                                   </div>  
                                 </div>  
                                 <span class="SmallCaptionText">  
                                        <span runat="server" id="PrimaryPercent">  
                                        </span>%&nbsp;of&nbsp;<span runat="server" id="PrimaryTotal">  
                                        </span>&nbsp;(<span runat="server" id="Speed"></span>)&nbsp;<a   
                                        href="javascript:cancelUpload();">Cancel</a>  
                                 </span>  
                             </ProgressTemplate>  
                        </telerik:RadProgressArea>                  
                    </div>  
                </td>  
            </tr>  
        </table>                   
 

Thanks,

- Brad
0
Accepted
Veselin Vasilev
Telerik team
answered on 25 Aug 2008, 11:47 AM
Hello Brad Docimo,

We are aware of the first problem - it will be fixed in the forthcoming service pack 1 in the middle of this week.
About the second problem - I guess you mean this javascript method: cancelUpload

You need to obtain the reference to the progress area first by:

var area = $find("<%= RadProgressArea1.ClientID %>");
area.cancelRequest();


All the best,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Upload (Obsolete)
Asked by
Brad Docimo
Top achievements
Rank 1
Answers by
Paul
Telerik team
Brad Docimo
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or