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

[Solved] Problem while validation FileSize on Client

2 Answers 128 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Ole Albers
Top achievements
Rank 2
Ole Albers asked on 24 Apr 2009, 09:11 AM
Hi there.
I used the the FAQ-article to check the file-size of an uploaded File on client-side.

The Code Snippet looks like this:
<telerik:RadCodeBlock ID="RadCodeBlock12" runat="server">     
     <script language="javascript" type="text/javascript"
function CheckUploadedFilesSize(progressArea, args) { 
            try { 
                
                alert(progressArea.Confirmed); // undef 
                alert(args.ProgressData);      // undef 
                if (!progressArea.Confirmed && args.ProgressData.RadUpload.RequestSize > 100000000) { 
                    alert('<asp:Literal runat="server" Text="<%$Resources:TextResources, ERROR_FILE_TO_BIG%>" />'); 
                   // document.close(); 
                    progressArea.cancelRequest(); 
                } 
            } catch (e) { 
                // Ignore... 
            } 
        } 
</script> 
    </telerik:RadCodeBlock> 
[...]
<form ...>
<RadFormDecorator... />
<RadScriptManager... />
<RadAjaxManager ... />
<RadAjaxPanel...>
[...]
<telerik:RadUpload ID="radUpload1" runat="server" ControlObjectsVisibility="ClearButtons" 
                         Culture="German"  
                         Language="de-DE" OverwriteExistingFiles="true" SkinID="Uploader" Width="100%" Height="100%" MaxFileInputsCount="5" InitialFileInputsCount="3" MaxFileSize="1048576" > 
                         <Localization Add="<%$Resources:TextResources, UPLOADER_ADD%>"  
                             Clear="<%$Resources:TextResources, UPLOADER_CLEAR%>"  
                             Select="<%$Resources:TextResources, UPLOADER_SELECT%>"  /> 
                        </telerik:RadUpload> 
                        <telerik:RadProgressArea Visible="true" runat="server" id="RadProgressArea1" /> 
                        <telerik:RadProgressManager ID="Radprogressmanager1" runat="server" OnClientProgressUpdating="CheckUploadedFilesSize"/>
[...]
</RadAjaxPanel></form>
     
When calling the the JS-Method by OnClientProgessUpdating-Event in RadProgressArea (like suggested in the FAQ-Article) args.progressData is undefined. When calling the Method from RadProgressManager args.progressData is defined and the messagebox is shown when the file is to big. Sadly, progressArea.cancelRequest does not to work because progressArea is undefinded (in both cases: calling from RadProgressManager as well as call from RadProgressArea)

Any clue what causes this problem?

2 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 27 Apr 2009, 12:25 PM
Hello Ole,

The article was updated long time ago and you can check it online at this URL:
http://www.telerik.com/help/aspnet-ajax/upload_howtoclientfilesize.html

I hope this helps.

Greetings,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ole Albers
Top achievements
Rank 2
answered on 27 Apr 2009, 01:29 PM
Worked. Nonetheless I'm really surprised to have used the wrong code as my Link is exactly the same than yours.

Well. Don't care. It now works and that's all that counts :)
Tags
Upload (Obsolete)
Asked by
Ole Albers
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Ole Albers
Top achievements
Rank 2
Share this question
or