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

disable RadWindow

3 Answers 58 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Iron
Kjell asked on 01 Feb 2014, 01:14 PM
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....

3 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 04 Feb 2014, 11:43 AM
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.
0
Kjell
Top achievements
Rank 1
Iron
answered on 07 Feb 2014, 01:10 PM
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
0
Vessy
Telerik team
answered on 12 Feb 2014, 12:19 PM
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.
Tags
FileExplorer
Asked by
Kjell
Top achievements
Rank 1
Iron
Answers by
Dobromir
Telerik team
Kjell
Top achievements
Rank 1
Iron
Vessy
Telerik team
Share this question
or