In a recent post, we explained how to open a local document by uploading it to the server. This sample project shows how to add a Download button to the ribbon file menu that downloads the document as an Adobe PDF file.

HTML5: Adding a download button to the ribbon file menu

As in other samples, a hidden button is used that will be triggered inside an AJAX UpdatePanel to keep up the existing WebSocket connection. In the event handler, the document is saved using the SaveText method and temporary stored in a session variable. Finally, a client-side Javascript is injected to the DOM which creates a hidden IFRAME element that calls the same ASPX page with a separate HTTP context. This way, a post back is not required and the Web.TextControl won't be disconnected from the server.

Loading...

The dynamically added Javascript calls the index.aspx page again with the query string document=1. This jumps directly into the Page_Load event where the stored document from the session variable is returned to the hidden IFRAME that will open the document in the browser.

Loading...

Download the sample from GitHub and test it on your own.

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on github.com/TextControl.

Please fork and contribute.

Requirements for This Sample

  • Visual Studio 2012 or better
  • TX Text Control .NET Server for ASP.NET (trial sufficient)