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

EnableOpenFile and DBContentProvider

5 Answers 101 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Andreas Kaech
Top achievements
Rank 1
Andreas Kaech asked on 10 Dec 2009, 12:09 PM
Hi Telerik,
when I want to open a file using DBContentProvider, there is an issue with the opening RadWindow:
The file can't be loaded into this window. This is not a problem in my application, but I don't find a routine to prevent opening this RadWindow.

Best regards,
Andreas

5 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 15 Dec 2009, 01:00 PM
Hi Andreas,

 You can prevent opening the file in a RadWindow by setting the EnableOpenFile="false" property of the RadFileExplorer control.

I hope this helps.

 
Sincerely yours,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andreas Kaech
Top achievements
Rank 1
answered on 16 Dec 2009, 07:32 AM
Hi Fiko,
I need to open the file, so I can't set EnableOpenFile to false.
My problem is, that the file don't open in the window, because of the DbContentProvider. Is it possible to rewrite the provider so that the file opens in the provided window?

Thanks and regards,
Andreas
0
Fiko
Telerik team
answered on 18 Dec 2009, 02:01 PM
Hi Andreas,

If I correctly understand you, you need the double clicked file to be opened in the default RadWindow such as in the FileExplorer's default demo. If this is your requirement, you need to change the Handler.ashx file in order to achieve the result - you need to remove the highlighted code from the WriteFile method:
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);
    if (extension != ".htm" && extension != ".html" && extension != ".xml")
    {
        response.AddHeader("content-disposition", "attachment; filename=" + fileName);
    }
    response.BinaryWrite(content);
    response.Flush();
    response.End();
}

For your convenience I have attached a fully working project to the thread (you need to add the bin folder with the Telerik.Web.UI.dll file)

I hope this helps.

Regards,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andreas Kaech
Top achievements
Rank 1
answered on 18 Dec 2009, 04:43 PM
Hi Fiko,
thanks, this was the right hint - but in Firefox, there is an issue: An error says, that the file could not be read (or something similar - I translated from german).
Do you know a solution for this problem?

Thanks and best regards,
Andreas
0
Accepted
Fiko
Telerik team
answered on 19 Dec 2009, 01:43 PM
Hello Andreas,

I am not sure what is causing the "file could not be read" error in your case and I was not able to reproduce the problem on my side.

I tested, however, my project in FF and found that when an image is double clicked a download dialog appears instead of preview window. In order to avoid this I modified the WriteFile method as follows:
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);
    if (extension != ".htm" && extension != ".html" && extension != ".xml")
    {
        response.AddHeader("content-disposition", "inline; filename=" + fileName);
    }
    response.BinaryWrite(content);
    response.Flush();
    response.End();
}

In case that you still experience the same error, could you please open a new support ticket and send me your exact setup where I can reproduce the error. Once I have a better view over your configuration I will do my best to provide a solution.

I hope this helps.

Greetings,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
FileExplorer
Asked by
Andreas Kaech
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Andreas Kaech
Top achievements
Rank 1
Share this question
or