开发者

silverlight open document

I have a browser hosted SL app. What I'd like is simple: the app generates a document (xls, doc, jpg...), the user clicks a button, then optionally a dialog box appears whe开发者_Go百科re he needs to click okay, then Excel, Word, a picture viewer or whatever starts and opens the document that the SL app created.

What I've seen so far are incomplete solutions.

Most people suggest to pop up a SaveFileDialog. First of all, after saving, the user needs to find the file first to open it, and he usually doesn't even want to save it in the first place, just view it. Bad UX.

Another possible solution is to save the file in isolated storage and start Excel with COM interop. But I believe there's no COM interop in the browser host, and COM interop is very platform dependent. My SL app should work with Moonlight, too.

Then others suggest to redirect the browser from SL to the HTTP location of the document. This can work, but this doesn't really solve my problem though, because then I need to put the document on the server somehow.

Anyone know of a real solution? A 'no' can be accepted as an answer here, too.


The definitive answer is: no. What you really want to do from an in browser host would breach the security that we expect from the Silverlight plugin.

The upcoming Silverlight 5 goes someway toward your requirement allowing system admins to use group policy to grant trusted behaviour to certain xaps that run inbrowser but whether this solution will stretch to moonlight (and if ever when that would happen) is anyone's guess.

Some questions that might be worth you considering, why is it the responsibilty of the Silverlight app running on the client to generate the document? Is it just for scalability reasons? If not why move the document generation code to the server?


If the File is saved on server side then we can open that file using the below code

string uri = HtmlPage.Document.DocumentUri.ToString();
uri = uri.Remove(uri.LastIndexOf('#'), uri.Length - uri.LastIndexOf('#'));
uri=uri.Remove(uri.LastIndexOf('/'));
System.Windows.Browser.HtmlPage.PopupWindow(new Uri(uri + "/FolderName/filenamewithextension"), "_blank", null);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜