How to Preview image using telerik RadAsyncUpload and RadBinaryImage in ASP AJAX Panel?

2 posts, 0 answers
  1. Lalitha
    Lalitha avatar
    2 posts
    Member since:
    May 2015

    Posted 22 May 2015 Link to this post


     I'm New to telerik..Can any one tell me how to get preview of the image and also save to database ..Im using RadAsyncUpload...this is the code I'm Using 

      protected void RadAsyncUpload_FileUploaded(object sender, FileUploadedEventArgs e)
                string path = Server.MapPath("~/Uploads/");
                e.File.SaveAs(path + e.File.GetName());
                string ext = e.File.GetExtension();


    Thank you 

  2. Hristo Valyavicharski
    Hristo Valyavicharski avatar
    975 posts

    Posted 27 May 2015 Link to this post

    Hello Lalitha,

    You can use this code for previewing:

    <script type="text/javascript">
         function fileUploaded(sender, args) {
             var manager = $find("ajaxManager");
     <telerik:RadAjaxManager runat="server" ID="ajaxManager">
             <telerik:AjaxSetting AjaxControlID="ajaxManager">
                     <telerik:AjaxUpdatedControl ControlID="upload" />
                     <telerik:AjaxUpdatedControl ControlID="preview" />
     <telerik:RadAsyncUpload runat="server" ID="upload" OnFileUploaded="upload_FileUploaded" OnClientFileUploaded="fileUploaded"></telerik:RadAsyncUpload>
     <telerik:RadBinaryImage runat="server" ID="preview" />
    protected void upload_FileUploaded(object sender, FileUploadedEventArgs e)
        BinaryReader reader = new BinaryReader(e.File.InputStream);
        Byte[] data = reader.ReadBytes((int)e.File.InputStream.Length);
        preview.DataValue = data;

    This demo shows how to preview and insert images into database with RadAsyncUpload.

    I hope this helps.

    Hristo Valyavicharski
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top