ASP.NET WebForms
|
<< Click to Display Table of Contents >> Navigation: Gnostice Document Studio .NET > Going Deeper > Document Viewing > ASP.NET > Displaying server-side documents > ASP.NET WebForms |
Steps to load server-side document in an ASP.NET WebForms application is listed as follows.
1.Setup a simple document viewer control in ASP.NET WebForms application as explained in the Getting Started section.
2.Copy input document to App_Data folder in your application.
3.In server side code, add the below code snippet in Page_Load event of the main Web Form (Viewer.aspx). You need to switch "Code" view for the form.
protected void Page_Load(object sender, EventArgs e) new Gnostice.Controls.ASP.ViewerController();
|
The Page_Load event will initialize the ViewerController and load the document to the server and a unique document URI is generated which includes resource identifier to the loaded document.
4.In the web form, add the below JavaScript code snippet.
<script type="text/javascript">
|
The displayServerDocumentInViewer() JavaScript function will load the document by getting the document URI set in server side through document.getElementById() function call.
5.On loading the webpage, the displayServerDocumentInViewer() JavaScript method must be invoked, so set this method in <body> tag of your web form like below.
<body onload="displayServerDocumentInViewer()">
|
6.Run the application in your favorite browser.