EnableOpenFile and DBContentProvider

6 posts, 1 answers
  1. Andreas Kaech
    Andreas Kaech avatar
    121 posts
    Member since:
    Sep 2004

    Posted 10 Dec 2009 Link to this post

    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
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 15 Dec 2009 Link to this post

    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.
  3. Andreas Kaech
    Andreas Kaech avatar
    121 posts
    Member since:
    Sep 2004

    Posted 16 Dec 2009 Link to this post

    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
  4. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 18 Dec 2009 Link to this post

    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.
  5. Andreas Kaech
    Andreas Kaech avatar
    121 posts
    Member since:
    Sep 2004

    Posted 18 Dec 2009 Link to this post

    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
  6. Answer
    Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 19 Dec 2009 Link to this post

    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.
Back to Top