There is any way to open an office file (word, access, excel, etc) inside an Object? The idea is send the path to an ASP.NET page and that page shows the document.
Thanks for your help.
BriegaHello briega,
If your goal is simply to display an Office document from inside an ASP.NET page, you needn't go to great lengths in order to do so; a simpler approach is to have an <iframe> element with runat="server" in your page, and set that IFrame's src attribute to the document you want using server-side code. Assuming the client has Office installed, the following code should do what you want:
<%@. Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<script runat="server">
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
IF1.Attributes("src") = "readme.doc"
End Sub
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>
<br>
<iframe runat="server" id="IF1"></iframe>
</form>
</body>
</HTML>
If you want to try this out, make sure there's a Word document called "readme.doc" in the same folder as the page.
Hope this helps.
It's a good solution, but the path is still visible in the source code and I'm having problems displaying the file in Netscape. Is there another way?
Netscape does not provide full support for the IFRAME element, yet. You can try the same solution using a regular FRAME. However this may pose some design challenges if you want to position the document whithin your page.
As for seeing the path in view source. You may want to use client side code and embed it a .js file. However, if you keep the .js file somewhere that is accessible via HTTP a web savvy user will still be able to get at the path. Let me know how stringent your security requirement is and I'll try to provide an efficient solution.
The client side code you want, is as follows:
FILE: showdocument.js
function showDoc(strFrameID)
{
var objFrame = document.getElemtById(strFrameID)
objFrame.src = "readme.doc
}
In your .aspx page replace the server-side script with the following:
<SCRIPT language="javascript" src="http://pics.10026.com/?src=showdocument.js"></script>
change your button to this:
<input type="submit" value="click" onclick="showDoc('frameID');return false;">
Here's Microsoft's documentation on the FRAME element
If you need more let me know.
I need a hi secure system. I dont want to show the path because some files are outside the server.
Once you've to send the document to the client, some address will be visible somewhere. E.g. if you would use an embedded Windows Forms control (only possible for IE) inside the browser, there will be a reference to the document which should be loaded in the HTML-source (as a parameter for the embedded <object>). One possibility is to copy the document which should be loaded to a temp folder on the server and send this document back to the client. When the session of the client expires (using an event handler in global.asax), you can delete the whole temporary folder from the machine. However, I think this will cause a lot of overhead but it should work. Of course, you should make a seperate folder for every session which is started.
Thanks for your help,
I thought that ASP.NET had some kind of object that works like IFRAME and the file could be opened in the server and then ASP.NET displays to you an image of it, like when you are working with PCAnywhere.
Regards
0 comments:
Post a Comment