Asynchronous loading
Load a server document
Request Base64 document data from this demo's controller and load it into the existing viewer instance.
Client-side requestReplace the current document
Fetch Base64 data from the controller and load it without navigating the page.
ASYNC
1Request and load
The existing viewer instance remains mounted throughout the update.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Load asynchronously from JavaScript
Fetch Base64 document data from a focused controller endpoint and load it into the existing viewer instance without navigating away.
API used
TXDocumentViewer.loadDocument
Key members
The viewer can be initialized once and receive document data later, keeping the page responsive while a server request completes.
const response = await fetch("/document");
const data = await response.json();
TXDocumentViewer.loadDocument(data.base64, data.name);
How it works
The Razor helper prepares the browser viewer and its document. Demo-specific JavaScript uses the public TXDocumentViewer API and remains encapsulated with this demo.
NuGet packages
Displays supported document and PDF formats in the browser.
dotnet add package TXTextControl.Web.DocumentViewer --version 34.2.0
Source files
See the implementation
The view, browser behavior, assets, and controller are encapsulated in Demos/DocumentViewer/Loading/FromJavaScript.