disable RadWindow

4 posts, 0 answers
  1. Kjell
    Kjell avatar
    203 posts
    Member since:
    May 2011

    Posted 01 Feb 2014 Link to this post

    I am using the example DBContentProvider-Vb.
    How do i disable RadWindow to open when i want to download  a images, pdf, ecxel and other files?
    I only want to have the download dialog....
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 04 Feb 2014 Link to this post

    Hi Kjell,

    To download files instead of open them you need to pass the files as an attachment through the content provider's handler. Please review the following live demo demonstrating such implementation:
    http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/filteranddownloadfiles/defaultcs.aspx

    Regards,
    Dobromir
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kjell
    Kjell avatar
    203 posts
    Member since:
    May 2011

    Posted 07 Feb 2014 in reply to Dobromir Link to this post

    It works for all file extensions in addition to pictures. This will open the image in the browser. I want to get the dialog to download the image. See attached Open.png that I get with other file extensions.
    Open.png

    var requestImage = "Handler.ashx?path=" + item.get_url(); does not work, get double Handler.ashx? path ....
    this works: var requestImage = item.get_url();

    function OnClientFileOpen(oExplorer, args) {
        var item = args.get_item();
        var fileExtension = item.get_extension();
     
        if (fileExtension == "jpg" || fileExtension == "gif" || fileExtension == "png" || fileExtension == "pdf") {
            args.set_cancel(true);
     
            // var requestImage = "Handler.ashx?path=" + item.get_url(); This not work.....
            var requestImage = item.get_url();
            document.location = requestImage;
        }
    }

    http://www.junis.net/test/FileExplorer.aspx
  5. Vessy
    Admin
    Vessy avatar
    1388 posts

    Posted 12 Feb 2014 Link to this post

    Hi Kjell,

    FileExplorer is already using a generic handler when working with a DB provider, this is why it is enough to request directly the item by its url. The other thing you have to do is to implement the download logic from the handler from the demo to the one used in your application.

    Commenting the following if statement in the Handler.ashx file will allow you to download all type of files:
    private void WriteFile(byte[] content, string fileName, string contentType, HttpResponse response)
    {
        response.Buffer = true;
        response.Clear();
        response.ContentType = contentType;
        string extension = System.IO.Path.GetExtension(fileName).ToLower();
        //if (extension != ".htm" && extension != ".html" && extension != ".xml" && extension != ".jpg" && extension != ".gif" && extension != ".png")
        //{
            response.AddHeader("content-disposition", "attachment; filename=" + fileName);
         
        //}
        response.BinaryWrite(content);
        response.Flush();
        response.End();
    }

    I hope this helps.

    Regards,
    Veselina Raykova
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top