Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Upload / Validation

Select images to upload (jpg, jpeg, png, gif)

File size limit 500 KB, 1 MB total.


  • RadAsyncUpload can automatically validate files using the AllowedFilesExtensions properties and the MaxFileSize property. All files with invalid extensions are rejected on the client, without wasting bandwidth to upload them to the server.

    RadAsyncUpload provides client-side event called OnClientValidationFailed. It is fired when the selected file has invalid extension or its size is higher than the MaxFileSize property.

    The sever-side FileUploaded event is fired separately for each and every uploaded file. Each file can be marked as a valid or invalid using the IsValid property of FileUploadedEventArgs. Valid files are automatically saved to the target folder.

    Forth from Q1 2011 RadAsyncUpload supports file filtering. A file filter is an object with two properties -- Description and Extensions. The extensions property accepts a comma separated list of extensions, upon which the select file dialog should be filtered. The description property, as its name suggest, describes the extensions set.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="VB" AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="Upload_Examples_AsyncUpload_Default" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        <qsf:HeadTag runat="server" ID="Headtag1" />
        <link href="Styles.css" rel="Stylesheet" type="text/css" />
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <qsf:Header runat="server" ID="Header1" NavigationLanguage="VB" />
        <telerik:RadScriptManager ID="ScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Buttons" />

        <script type="text/javascript">
        //<![CDATA[
            function validationFailed(sender, eventArgs) {
                $(".ErrorHolder").append("<p>Validation failed for '" + eventArgs.get_fileName() + "'.</p>").fadeIn("slow");
            }
         //]]>
        </script>

        <div class="MainWrap">
            <div class="TopWrap">
                <div class="Holder">
                    <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" AllowedFileExtensions="jpg,jpeg,png,gif"
                        MaxFileSize="524288" OnClientValidationFailed="validationFailed"
                        OnFileUploaded="RadAsyncUpload1_FileUploaded" InputSize="42">
                    </telerik:RadAsyncUpload>
                    <asp:Button runat="server" ID="BtnSubmit" Text="Submit" />
                    <p>
                        Select images to upload (jpg, jpeg, png, gif)
                    </p>
                    <p>
                        File size limit 500 KB, 1 MB total.
                    </p>
                    <div class="ErrorHolder">
                    </div>
                </div>
                <div class="Holder Right">
                    <asp:Panel runat="server" ID="ResultsPanel" Visible="false">
                        <asp:Panel ID="ValidFiles" Visible="false" runat="server">
                            <p>
                                <strong>Images saved to the target folder:</strong>
                            </p>
                        </asp:Panel>
                        <asp:Panel ID="InvalidFiles" Visible="false" runat="server">
                            <p>
                                <strong>The following images were not saved due to exceeding the maximum total size:</strong>
                            </p>
                        </asp:Panel>
                    </asp:Panel>
                </div>
                <div class="BottomWrap">
                </div>
            </div>
        </div>
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451