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

Opening local file

11 Answers 619 Views
Window
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 17 Jul 2009, 03:50 PM
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

Andi

11 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 20 Jul 2009, 11:29 AM
Hello Andi,

RadWindow works with URLs so you need to use an absolute or relative URL to that file on your server.
e.g.
NavigateUrl = "http://mysite.com/myfolder/myfile.pdf"

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.
0
saritha78
Top achievements
Rank 1
answered on 18 Dec 2009, 07:57 PM
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;

Thanks,
Saritha
0
Andreas
Top achievements
Rank 1
answered on 18 Dec 2009, 11:41 PM

 
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">  
 </telerik:RadWindow>  
 
 </div> 

 
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">  
    </telerik:RadWindowManager> 

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

Andi

0
Fiko
Telerik team
answered on 19 Dec 2009, 12:26 PM
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,
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
saritha78
Top achievements
Rank 1
answered on 21 Dec 2009, 06:55 PM
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.
0
Daniel Aquere
Top achievements
Rank 2
answered on 18 Aug 2011, 05:30 PM
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

Daniel
0
Marin Bratanov
Telerik team
answered on 22 Aug 2011, 02:22 PM
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,
Marin
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 >>

0
Dinesh Kumar
Top achievements
Rank 1
answered on 09 Jan 2019, 05:55 AM

Is it possible to open files present in a client machine rather than from server with telerik controls?

I am trying to open files from (C: drive ) in my local machine on click of File path hyperlink present in a web application.

0
Marin Bratanov
Telerik team
answered on 09 Jan 2019, 09:25 AM
Hi Dinesh,

If you can set the correct path to a simple <iframe> with JavaScript, the same approach will work with RadWindow too.


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dinesh Kumar
Top achievements
Rank 1
answered on 09 Jan 2019, 12:05 PM

Hi Marin,

By Opening I am mean, Launching the local file with the file's respective default program in client machine[quote]

Marin Bratanov said:Hi Dinesh,

If you can set the correct path to a simple <iframe> with JavaScript, the same approach will work with RadWindow too.


Regards,
Marin Bratanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.

[/quote],

Is it possible with telerik controls?

0
Marin Bratanov
Telerik team
answered on 09 Jan 2019, 12:11 PM
Hello Dinesh,

You can't do that. JavaScript cannot touch the PC, it is sandboxed in the browser, and that's a security feature that cannot be circumvented without things like Flash or Java applets. RadWIndow loads content from the designated URI and that's all it can do for you, it cannot hack the user's PC.


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Window
Asked by
Andreas
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
saritha78
Top achievements
Rank 1
Andreas
Top achievements
Rank 1
Fiko
Telerik team
Daniel Aquere
Top achievements
Rank 2
Marin Bratanov
Telerik team
Dinesh Kumar
Top achievements
Rank 1
Share this question
or