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

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

2 Answers 510 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Lalitha
Top achievements
Rank 1
Lalitha asked on 22 May 2015, 09:07 AM

Hello,

 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 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 27 May 2015, 06:36 AM
Hello Lalitha,

You can use this code for previewing:

<script type="text/javascript">
     function fileUploaded(sender, args) {
         var manager = $find("ajaxManager");
         manager.ajaxRequest();
     }
 
 </script>
 
 <telerik:RadAjaxManager runat="server" ID="ajaxManager">
     <AjaxSettings>
         <telerik:AjaxSetting AjaxControlID="ajaxManager">
             <UpdatedControls>
                 <telerik:AjaxUpdatedControl ControlID="upload" />
                 <telerik:AjaxUpdatedControl ControlID="preview" />
             </UpdatedControls>
         </telerik:AjaxSetting>
     </AjaxSettings>
 </telerik:RadAjaxManager>
 
 <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.

Regards,
Hristo Valyavicharski
Telerik
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
0
lakshmi
Top achievements
Rank 1
answered on 12 Sep 2017, 10:58 AM
Hi,I m new to Telerik controls.now i selected one image(I used telerik:RadAsyncUpload) after seleted the img(HTML img Tag) it is showing in the preview whatever we selected img.Now i m dng some postback.after doing the postback also i have to show the currently selected img in preview.Now it is showing previously selected img.Pls help me. It is urgent for me.
Tags
AsyncUpload
Asked by
Lalitha
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
lakshmi
Top achievements
Rank 1
Share this question
or