HTML5: Loading Local Documents - Part 2
In a recent blog entry, we showed how to load a local document using pure Javascript and an HTML input element. In this second part, we show how to hide the HTML input element and to overwrite the Open functionality in the ribbon bar. The input element is hidden using the CSS property display: Using Javascript, a new event is attached to the Load menu item of the ribbon bar. The newly attached event is raised before it is bubbled to Web.TextControl. This enables the cancellation of the…

In a recent blog entry, we showed how to load a local document using pure Javascript and an HTML input element. In this second part, we show how to hide the HTML input element and to overwrite the Open functionality in the ribbon bar.
The input element is hidden using the CSS property display:
<input style="display: none; margin-bottom: 20px;" type="file" id="fileinput" />
<cc1:TextControl ID="TextControl1" runat="server" />
Using Javascript, a new event is attached to the Load menu item of the ribbon bar. The newly attached event is raised before it is bubbled to Web.TextControl. This enables the cancellation of the default functionality of the ribbon item in order to add your own action:
TXTextControl.addEventListener("ribbonTabsLoaded", function (e) {
addAction();
});
function addAction() {
document.getElementById("fileMnuItemOpen").addEventListener("click",
function (e) {
document.getElementById('fileinput').click();
e.cancelBubble = true;
});
}
When clicking the Open menu item now, the local Open File dialog is opened. Users can now upload local files or files from connected cloud services such as OneDrive:
Download the sample from GitHub and test it on your own.
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 (trial sufficient)
Reporting
The Text Control Reporting Framework combines powerful reporting features with an easy-to-use, MS Word compatible word processor. Users can create documents and templates using ordinary Microsoft Word skills. The Reporting Framework is included in all .NET based TX Text Control products including ASP.NET, Windows Forms and WPF.
Related Posts
Creating Your First ASP.NET Reporting Application
This tutorial shows how to use the MailMerge component in an ASP.NET Web application to merge a template with data to create an Adobe PDF document.
Automatically Reconnect to the Server and Recover the Document
We just published a sample project that shows how to reconnect to the server and how to recover the current document.
JavaScript API: Working with Merge Fields
This article gives an overview of how to add, remove and manipulate merge fields programmatically using the JavaScript API.
Technology Preview: Embeddable HTML Widget to integrate Document Editing to…
This technology preview shows an early version of an HTML widget that can be embedded into any HTML page.
Embedding TXTextControl.Web in non-.NET Framework applications like .NET…
This article shows how to embed the ASP.NET MVC component TXTextControl.Web into non-.NET Framework applications.