TX Text Control .NET for Windows Forms Documentation

Creating a simple ASP.NET project using the DocumentViewer

The source code is contained in the following directories:

  • %USERPROFILE%\My Documents\TX Text Control 17.0.NET for WPF\Samples\ASP.NET\VB.NET\DocumentViewer
  • %USERPROFILE%\My Documents\TX Text Control 17.0.NET for WPF\Samples\ASP.NET\CSharp\DocumentViewer
  • %USERPROFILE%\My Documents\TX Text Control 17.0.NET for Windows Forms\Samples\ASP.NET\VB.NET\DocumentViewer
  • %USERPROFILE%\My Documents\TX Text Control 17.0.NET for Windows Forms\Samples\ASP.NET\CSharp\DocumentViewer

Used TX Text Control controls:

  • DocumentServer.DocumentViewer
  • DocumentServer.DocumentController
  • TXTextControl.ServerTextControl

Relevant API links:

1. Open Visual Studio 2008 and choose File, New, Project... to open the New Project dialog box.

2. To create a new web project, select Web from the Project types. Select the ASP.NET Web Application as the project type and choose an appropriate name for your project like in the screenshot below. Confirm with OK to create the new web project.

3. Select the Default.aspx page in the Solution Explorer and choose Component Designer from the View main menu.

4. Choose Select toolbox items... from the Tools main menu to open the Choose Toolbox Items dialog box. Sort by Namespace and check the ServerTextControl, DocumentViewer and the DocumentController components from the TXTextControl namespace.

The components should now be visible in the toolbox:

5. Drag and drop an instance of the ServerTextControl and the DocumentController to the form. It should look like this:

6. Select the DocumentController component and bind the ServerTextControl component to it. This can be done in the Properties window by choosing serverTextControl1 in the TextComponent property.

7. Switch to the design view of the Default.aspx page and drag and drop a DocumentViewer control from the toolbox onto the page.

8. In the Properties Window of Visual Studio, set the size of the control to a proper size in pixels. For example, set the Width property to 1000px and the Height property to 650px .

9. Save a document of one of the types specified in DocumentServer.FileFormat in the project's folder. For the purpose of this tutorial we assume the document is named Demo.rtf and is of type RichTextFormat. Please make sure the file extension matches the file type, since the DocumentServer.Web.DocumentViewer determines the file's type by checking its extension. The fallback file type for unrecognized extensions is the internal TextControl format. Thus, for files of this type you can use every extension except the following three: .doc, .docx and .rtf.

10. Open the code view of Default.aspx.cs.

11. Add the following code to the page's load event:

[C#] protected void Page_Load(object sender, EventArgs e) { InitializeComponent(); DocumentViewer1.DocumentController = documentController1; DocumentViewer1.LoadDocument(Server.MapPath("Demo.rtf")); }
[Visual Basic] Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load InitializeComponent() DocumentViewer1.DocumentController = documentController1 DocumentViewer1.LoadDocument(Server.MapPath("Demo.rtf")) End Sub

12. Start the application by pressing F5.

 
 
 

Products

Support

Downloads

Corporate

Buy Now