Trying to set document to be loaded from code behind
Problem reported by Sanjay SHah - September 9, 2018 at 4:25 AM
Not A Problem
HI,
 
I am currently evalutingDoucmentUltimate and trying to set the document to be loaded from the code behind in my webforms application.
            <GleamTech:DocumentViewerControl runat="server" 
                Width="800" 
                Height="600" 
                Document="~/Documents/test" />
Could someone please provide a simple example,
 
I tried the following:
 DocumentViewerControl.Document = "~/TestDocument.doc"
Error    25    'DocumentViewerControl' is not declared. It may be inaccessible due to its protection level.    WordExcelTest.aspx.vb
 
Could someone please provide a simple example.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

4 Replies

Reply to Thread
0
Cem Alacayir Replied
Employee Post
You need to access any ASP.NET WebForms control via it's ID in codebehind. When not specified the default ID for DocumentViewerControl is "documentViewer" so you can use this:
documentViewer.Document = "~/TestDocument.doc"
 
or you can specify a custom ID:
<GleamTech:DocumentViewerControl runat="server" 
        ID="documentViewer2"
        Width="800" 
        Height="600" 
        Document="~/Documents/test" />
 
 
0
Sanjay SHah Replied
Many thanks for replying.

When I add this:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WordExcelTest.aspx.vb" Inherits="OandViewSample.WordExcelTest" %>

<%@ Register TagPrefix="GleamTech" Namespace="GleamTech.DocumentUltimate" Assembly="GleamTech.DocumentUltimate" %>
<%@ Register TagPrefix="GleamTech" Namespace="GleamTech.DocumentUltimate.AspNet.WebForms" Assembly="GleamTech.DocumentUltimate" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">;
<head runat="server">
<title></title>
</head>
<body>
<form>

<GleamTech:DocumentViewerControl runat="server"
ID="documentViewer2"
Width="800"
Height="600"
Document="~/Documents/test" />
</form>
</body>
</html>

I receive an error:
Error 1 Type 'GleamTech.DocumentUltimate.AspNet.WebForms.DocumentViewerControl' is not defined. WordExcelTest.aspx.designer.vb 23 45

I also tried your other option:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WordExcelTest.aspx.vb" Inherits="OandViewSample.WordExcelTest" %>

<%@ Register TagPrefix="GleamTech" Namespace="GleamTech.DocumentUltimate" Assembly="GleamTech.DocumentUltimate" %>
<%@ Register TagPrefix="GleamTech" Namespace="GleamTech.DocumentUltimate.AspNet.WebForms" Assembly="GleamTech.DocumentUltimate" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">;
<head runat="server">
<title></title>
</head>
<body>
<form>
<GleamTech:DocumentViewerControl runat="server"
Width="100%"
Height="800"
Document="~/Documents/790-61010.dwg" />
</form>
</body>
</html>

CODE BEHIND:
Public Class WordExcelTest
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

documentViewer.Document = "~/TestDocument.doc"

End Sub

End Class

I receive an error:
Error 3 'documentViewer' is not declared. It may be inaccessible due to its protection level. WordExcelTest.aspx.vb 7 9

Many thanks for any help

0
Cem Alacayir Replied
Employee Post
Well, did you add References to GleamTech DLLs in your project?
Please follow "Getting Started" guide here:
https://docs.gleamtech.com/documentultimate/html/adding-references-to-documentultimate-assemblies.htm
Also examine the example VB project included in the download from our site.
0
Sanjay SHah Replied
Many thanks Cem, I will try adding the refs and revert back if I still encounter an issue.

Reply to Thread