Getting Started

This chapter shows how to create a small ASP.NET application from scratch with just a few lines of code. An instance of ServerTextControl is created, text is inserted, formatted and returned in HTML format.

The source code for this simple example is located in the following directories:

Language Project Location
C# %USERPROFILE%\Documents\TX Text Control 24.0.NET Server for ASP.NET\Samples\ASP.NET\CSharp\Documentation Tutorials\ServerTextControl\
VB.NET %USERPROFILE%\Documents\TX Text Control 24.0.NET Server for ASP.NET\Samples\ASP.NET\VB.NET\Documentation Tutorials\ServerTextControl\

Used TX Text Control classes:

Creating the application

1. Assuming that you have already run the TX Text Control .NET Server for ASP.NET installation program, start Visual Studio and create a new ASP.NET Web Application.

2. Choose Add New Item... from the Project main menu. In the opened dialog box Add New Item, select Web Form and confirm with OK.

In order to add non-visual components such as ServerTextControl to the Web form, the Component Designer surface of the ASPX page must be opened.

3. Select the newly created Web form in the Solution Explorer and choose Component Designer from the View main menu. Find the ServerTextControl in your Toolbox and drag and drop an instance onto the Component Designer view.

4. Open the Designer of the Web form using the Designer menu item of the View main menu. Add a Button control from the Toolbox to the Web form and double-click it to open the code-behind event handler.

Insert the following code to the button click event:

using (serverTextControl1)

	serverTextControl1.Text = "TX Text Control .NET Server for ASP.NET";

	TXTextControl.Selection selection = new TXTextControl.Selection(0, 15);
	selection.Bold = true;
	selection.FontSize = 300;

	serverTextControl1.Selection = selection;

	string data;
	serverTextControl1.Save(out data, TXTextControl.StringStreamType.HTMLFormat);
[Visual Basic]
Using serverTextControl1

	serverTextControl1.Text = "TX Text Control .NET Server for ASP.NET"

	Dim selection As New TXTextControl.Selection(0, 15)
	selection.Bold = True
	selection.FontSize = 300

	serverTextControl1.Selection = selection

	Dim data As String
	serverTextControl1.Save(data, TXTextControl.StringStreamType.HTMLFormat)
End Using

In the same Code view, call the InitializeComponent() in the Page_Load event:

protected void Page_Load(object sender, EventArgs e)
[Visual Basic]
Protected Sub Page_Load(sender As Object, e As EventArgs)
End Sub

Press F5 to compile and start the application. After clicking the button, the TX Text Control .NET Server creates the document and returns HTML text.

ServerTextControl should be used in a Using statement as an explicit object disposing is required.