RadAsyncUpdoad Example

We have some code for RadAsyncUpload on the site, but this is a fuller example

Related Articles

... and you 'll find more on the Telerik ASPNET Menu

 

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="Images.aspx.vb" Inherits="Driver.Images" %>
<asp:Content ID="Content1" ContentPlaceHolderID="header" runat="server">
    <script type="text/javascript">
        function OnRadAsyncUpload1ClientAction(source, args) {
            __doPostBack('RadAsyncUpload1', args);
        }
    </script>
 
    <style type="text/css">
        .ruButton.ruBrowse
            {
                background-image: url("images/camera.jpg") !important;
                background-repeat: no-repeat;
                background-position: 1px 1px;
                font-size:44px;  
            }
        div.RadUpload .ruFakeInput
        {
            visibility: hidden;
            width: 0;
            padding: 0;
        }
        div.RadUpload .ruBrowse
        {
            min-width:48px;
        }
    </style>
 
 
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Label runat="server" ID="lblError" CssClass="Error"></asp:Label>
    <table style="max-width:700px" class="Grid" border="0" >
        <tr>
            <td class="Title center">
                Images
            </td>
        </tr>
        <tr>
            <td class="center">
                <asp:label ID="lblTruck" runat="server"></asp:label>
            </td>
        </tr>
 
        <tr>
            <td>
                <asp:Label ID="Label1" CssClass="Error" runat="server">
                    Press the camera button<br />
                    Take pictures one at a time<br />
                    Wait for the green dot between pictures<br />
                    Press 'Save' to save the pictures
 
                </asp:Label><br />
                <telerik:RadAsyncUpload HideFileInput="false"  runat="server" ID="RadAsyncUpload1" PostbackTriggers="btnSave" 
                    OnClientFilesUploaded ="OnRadAsyncUpload1ClientAction" MultipleFileSelection="Automatic"  RenderMode="Lightweight"
                    AllowedFileExtensions=".jpeg,.jpg,.png" >
                    <Localization Select="Ca" />
                </telerik:RadAsyncUpload>
                <br />
                <br />
                <telerik:RadButton  ID="btnSave" runat="server" Text="Save" ></telerik:RadButton>
 
            </td>
        </tr>
    </table>
 
    <telerik:RadImageGallery RenderMode="Lightweight" BackColor="Transparent" runat="server" ID="RadImageGallery1" DisplayAreaMode="Image" 
            DataImageField="ImageBLOB" DataTitleField="Notes2"     >
    </telerik:RadImageGallery>   
</asp:Content>

 

Imports System
Imports System.Drawing
Imports Telerik.Web.UI
 
Public Class Images
    Inherits InheritedPage
    Dim mstrReturnTo As String
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim strError As String = ""
 
        Try
            If Session("RowID") Is Nothing Then
                FormsAuthentication.SignOut()
                Response.Redirect("Default.aspx")
            End If
 
            If Not IsPostBack Then
                Me.lblTruck.Text = "Truck " + Session("Truck")
            End If
 
        Catch ex As ThreadAbortException
        Catch ex As Exception
            ErrorHandler.globalErrorHandler(ex, strError, "Express", App.TabletUserName, False)
            Me.lblError.Text = ex.Message
        End Try
 
    End Sub
    Private Sub RadImageGallery1_NeedDataSource(sender As Object, e As ImageGalleryNeedDataSourceEventArgs) Handles RadImageGallery1.NeedDataSource
        Try
            Dim oDT As DataTable = SPs.fp_FPDocument_SEL_forDocs2(Session("RowID"), 15, "jpg", App.ConnectionString).getTable
            Me.RadImageGallery1.DataSource = oDT
            If oDT.Rows.Count = 0 Then
                Me.RadImageGallery1.Visible = False
                Exit Sub
            End If
 
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
 
 
    Private Sub RadAsyncUpload1_FileUploaded(sender As Object, e As FileUploadedEventArgs) Handles RadAsyncUpload1.FileUploaded
        Dim strError As String = ""
        Try
 
            'Dim oBmp As New Bitmap(RadAsyncUpload1.UploadedFiles(0).InputStream)
            Dim oBmp As New Bitmap(e.File.InputStream)
            Dim strComments As String = ""
            'scale the image smaller
            oBmp = ImageHandler.ScaleBitmapTo800(oBmp)
 
            'save to SQL
            Dim fileData As Byte() = ImageHandler.BitmapToByteArray(oBmp)
            Dim strDocName As String = String.Format("Delivery {0:MMdd}", Now)
            DynData.SPs.fp_FPDocument_MergeWSeq2(Session("RowID"), 15, "TRUCK", 0, fileData, strComments, "TRUCK", App.TabletUserName, strDocName, "jpg", App.ConnectionString).execute()
 
            RadImageGallery1.Rebind()
 
        Catch ex As ThreadAbortException
        Catch ex As Exception
            ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, False)
 
        End Try
 
    End Sub
    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        Dim strError As String = ""
        Try
            'doesn't do anything. Only here to cause the postback, so the RadAsyncUpload control will process (above)
 
        Catch ex As ThreadAbortException
        Catch ex As Exception
            ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, False)
            Me.lblError.Text = ex.Message
 
        End Try
 
    End Sub
End Class

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences