<Telerik:RadAjaxPanel> is preventing the "Download" ImageButton from forcing the browser open the "Save As" dialog box.

2 posts, 1 answers
  1. Mohd
    Mohd avatar
    1 posts
    Member since:
    Nov 2014

    Posted 16 Dec 2014 Link to this post

    Hi every body,

    I have a <asp:ImageButton> that is supposed to force the browser to open "Save As" dialog box in attempt to download an image into the client machine.
    The image was previously produced successfully in a previous process:

     Using bitmap As New Bitmap(188, 306)
                browser.DrawToBitmap(bitmap, New Rectangle(0, 0, 188, 306))
                Using stream As New MemoryStream()
                    bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png)
                    Dim bytes As Byte() = stream.ToArray()
                    myImage.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(bytes)
                End Using
     End Using

    and is shown successfully within the <asp:Image> tag.

    My Download ImageButton has the following code behind:

    Private Sub imgbtn_Download_Click(sender As Object, e As ImageClickEventArgs) Handles imgbtn_Download.Click
            Dim bytes As Byte() = Convert.FromBase64String(myImage.ImageUrl.Split(",")(1))
            Response.Buffer = True
            Response.Charset = ""
            Response.ContentType = "image/png"
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + "abc.png")
        End Sub

    I noticed that if the <asp:ImageButton> was placed inside <Telerik:RadAjaxPanel> the "Save As" dialog box doesn't pop up and the consequently download process doesn't start. However, if I shift the ImageButton control out of the <Telerik:RadAjaxPanel> it works successfuly.

    So is there any explanation from Telerik Team why such behavior is taking place. And is there any recommendation to make the "Save As" downlaod process succeeds while the <asp:ImageButton> is inside the <Telerik:RadAjaxPanel>?

  2. Answer
    Viktor Tachev
    Viktor Tachev avatar
    1453 posts

    Posted 19 Dec 2014 Link to this post


    The behavior you describe is default browser behavior. In order to download a file you need to temporarily disable AJAX for the ImageButton. Check out the following code snippets that illustrates the approach:

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="requestStart">
        <asp:ImageButton runat="server" Text="Download" ID="ImageButton1" OnClick="ImageButton1_Click" />

    function requestStart(sender, args) {
        if (args.get_eventTarget().indexOf("ImageButton1") != -1) {

    Viktor Tachev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Telerik UI for ASP.NET Core is out
Back to Top