Opening local file

8 posts, 0 answers
  1. Andreas
    Andreas avatar
    13 posts
    Member since:
    Jun 2009

    Posted 17 Jul 2009 Link to this post

    Hi All,

    with RadWindow I want to open a local PDF file like d://any.pdf

    I would be very happy about a hint how to achieve this.

    Many thanks

  2. Georgi Tunev
    Georgi Tunev avatar
    7207 posts

    Posted 20 Jul 2009 Link to this post

    Hello Andi,

    RadWindow works with URLs so you need to use an absolute or relative URL to that file on your server.
    NavigateUrl = ""

    Just make sure to set ShowContentDuringLoad to true - this is needed when opening non-web page files like pdf or doc in RadWindow.

    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft R3 2016 release webinar banner
  4. saritha78
    saritha78 avatar
    23 posts
    Member since:
    Dec 2009

    Posted 18 Dec 2009 Link to this post

    Can you give an example of how to open a local file?
    I am trying somehting like this and it is not working. This is my code in the OnClientClose of one radwindow where I want to open the file in another rad window. The window opens but it is blank, the file exists but it is not opened in the window. I have ShowContentDuringLoad set to trure for RadWindow2.

    In javascript:
    var ownd=radopen("file://C:/Users/admin/AppData/Local/Temp/abc.pdf","RadWindow2");
    return false;

    I have also tried the following, same result, rad window opens but the file does not.
    var ownd=radopen("C:/Users/admin/AppData/Local/Temp/abc.pdf","RadWindow2");
    return false;

  5. Andreas
    Andreas avatar
    13 posts
    Member since:
    Jun 2009

    Posted 18 Dec 2009 Link to this post

    RadWindow1.NavigateUrl = "http://99.999.999.999/User/User3/filename.pdf";  
    RadWindow1.VisibleOnPageLoad = true//opens the window 

    Hi Saritha,


    thats how it works for me.


    I am setting the url from code behind in c# and also set VisibleOnPageLoad to true, so that once the page is refreshed, the window opens (see above)

    On the aspx page I have the following code

    <div id="zoneDiv" class="windowTracking">  
    <telerik:RadWindow ID="RadWindow1" runat="server" Height="500px" Width="500px"   
                        CssClass="windowTracking" OffsetElementID="zoneDiv">  

    Formerly, I had the url in the html, but this did not work for me.

    Also, on the same aspx page I have

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">  

    Please let me know if this is something which you can use (considering that this code is server side and not client side as you maybe need it.

    I am using it from code behind as its easier for me to change the filename and not have it static. So multiple users can use the window at the same time as there are different file names and not just one file which is locked for one user.

    Best wishes


  6. Fiko
    Fiko avatar
    1406 posts

    Posted 19 Dec 2009 Link to this post

    Hi Saritha,

    RadWindow is based on an IFRAME and it behaves just like that. That is why you cannot open a file by its physical path (actually a physical path has \ as a path separator). In your case you need to use a relative path the same way as you set path to an IFRAME.
    For example:
    var ownd=radopen("abc.pdf","RadWindow2");

    The above code loads a PDF file - abc.pdf, that is located in the root directory of the application, in a new RadWindow.

    Best wishes,
    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.
  7. saritha78
    saritha78 avatar
    23 posts
    Member since:
    Dec 2009

    Posted 21 Dec 2009 Link to this post

    Thanks Fiko.
    So, basically it is easy to load from the server and not so easy to load from the client's machine. I will work around that.
  8. Daniel Aquere
    Daniel Aquere avatar
    85 posts
    Member since:
    Mar 2011

    Posted 18 Aug 2011 Link to this post

    Hi Fiko,

    Please, how can I open a file in the server using C# code?

    I´m using this approach, without sucess:

    protected void RadGrid1_GridExporting(object source, GridExportingArgs e)
            string vnome_arq = "relatorio_" + DateTime.Now.ToString("dd-MM-yy_HH-mm-ss") + "__" + t0302_projeto.SelectedItem.Text.Trim();
            string path = Server.MapPath("~/relatorios/" + vnome_arq + ".pdf");
            using (FileStream fs = File.Create(path))
                Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
                fs.Write(info, 0, info.Length);

            RadWindow1.NavigateUrl = "~/relatorios/" + vnome_arq + ".pdf";
            RadWindow1.ShowContentDuringLoad = true;
            RadWindow1.VisibleOnPageLoad = true;

    // THE WINDOW DON´T OPEN      


    Thanks, best

  9. Marin Bratanov
    Marin Bratanov avatar
    3555 posts

    Posted 22 Aug 2011 Link to this post

    Hello Daniel,

    Assuming that the file is available when you try to access it (i.e. the creation goes well) the RadWindow should be able to load it just like any iframe would.

    A possible reason why the RadWindow would not open in this scenario would be if this event is fired in an AJAX request where the RadWindow is not updated in the response. This means that the VisibleOnPageLoad property and the new url will not be sent to the client.

    What I can advise is that you inject a JavaScript function instead, for example:
    string script = "function f(){radopen(\"" + url + "\", \"RadWindow1\"); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(this, this.GetType(), "key", script, true);

    More information about this approach is available in this help article.

    All the best,
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top
DevCraft R3 2016 release webinar banner