Creating an instance of ServerTextControl

ServerTextControl is a non-UI .NET component that can be initialized in all .NET based applications.

In this demo, on the button click event, a new ServerTextControl instance is created. Formatted text is inserted using the Selection object and saved as HTML which is returned to a DIV element.



Using TX Text Control, documents can be imported and exported from and to DOC, DOCX, RTF, PDF, HTML and XML. Documents can be loaded and saved from and to streams, memory variables and physical files.


using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace tx_aspnet_samples.Basics
    public partial class create : System.Web.UI.Page
        protected void Button1_Click(object sender, EventArgs e)
            // create a new instance of ServerTextControl
            using (TXTextControl.ServerTextControl tx =
                new TXTextControl.ServerTextControl())
                // ServerTextControl must be "created"
                tx.Text = "TX Text Control .NET Server for ASP.NET\r\nThis HTML text" +
                    "has been created by ServerTextControl at " +
                    DateTime.Now.ToString() + ".";

                // create a new selection and apply some formatting
                TXTextControl.Selection selection = new TXTextControl.Selection(0, 15);
                selection.Bold = true;
                selection.ForeColor = Color.Red;

                // apply the selection to the ServerTextControl instance
                tx.Selection = selection;

                // save the content as HTML
                string sHTML;
                tx.Save(out sHTML, TXTextControl.StringStreamType.HTMLFormat);

                htmldiv.InnerHtml = sHTML;

ServerTextControl Basics