I have a Silverlight application that gets a list of contacts and displays them in a datagrid. The application needs to also support exporting the contacts to Excel and printing the contacts as an HTML page.
I'm using WCF RIA services to construct most of the query on the Silverlight client and then the server adds some additional where clauses to the query as well.
I'm trying to figure out if there is a way to run the results of the query using an ASP.Net page which will format them and prompt the user to download the results (or print the results).
The only idea I've come up with is to save the IQueryable object as a variable on the server side and return the key back to the Silverlight page. Then pass the key to either Export.aspx or Print.aspx which would grab the results of the query and return them.
Any better ideas?
It seems like there must be a better way that I'm just not thinking of.
Answer: 1
Unfortunately there isn't a better approach, at least what I'm aware of. We have been looking into this for our Excel export in silverlight as well. We tried opening a new browser window with a url, but you cannot add any headers or PUT data, which is what we needed. So unless you can completely encode your query in the URL, this approach will not work.
The approach we will be implementing is to save the exported result in storage and return a key to this result, as you mentioned in your question.
On the other hand, it does allow for some nice features, like enabling sending a link to the resource. This of course pulls in all the head-aches of permissions etc.
by : Philipp Aumayrhttp://stackoverflow.com/users/1288539Answer: 2
I've successfully generated Excel files using ExcelLite on the client side. Then it is a matter of prompting the user with a Save File dialog. You can do this generically for datagrids. Outputting HTML is not much harder.
by : Chui Teyhttp://stackoverflow.com/users/34461Answer: 3
So I was finally able to do this after a lot of work and research. To make it work I had to use some of the WCF RIA Services internal classes (via decompile) on the Silverlight side to generate the proper query string to pass to the ASP.Net page. Then on the server side I had to decompile even more classes to parse the query string and turn it into a valid Linq query. Now it all works and I can run the query in the code behind and output the results as a file.
If anyone is interested let me know and I can try to share the gory details. Thanks!
by : Bryanthttp://stackoverflow.com/users/10893
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog