Getting Started: Document Editor with ASP.NET Web Forms (.NET Framework)

This article shows how to use the TX Text Control ASP.NET document editor within a Web Forms application in Visual Studio 2022.

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

  • %USERPROFILE%\Documents\TX Text Control 32.0.NET Server for ASP.NET\CSharp\Web Forms\editor\
  • %USERPROFILE%\Documents\TX Text Control 32.0.NET Server for ASP.NET\VB.NET\Web Forms\editor\

Creating the Application

Make sure that you downloaded the latest version of Visual Studio 2022.

1. In Visual Studio 2022, create a new project by choosing Create a new project.

2. Select ASP.NET Web Application (.NET Framework) as the project template and confirm with Next.

3. Choose a name for your project, select .NET Framework 4.8 as the Framework and confirm with Create.

4. In the next dialog, choose Web Forms as the project template and confirm with Create.

Image

Adding TX Text Control References

1. While the project is selected in the Solution Explorer, choose Project -> Add Project Reference... to open the Reference Manager. In the opened dialog, select Browse... to select the required TX Text Control assemblies. Navigate to the installation folder of TX Text Control and select the following assembly from the Assembly folder:

  • TXTextControl.Web.dll

After selecting this assembly, click Add and close the Reference Manager by confirming with OK.

Adding the Control to the View

1. Find the Default.aspx file in the project's root folder. Except the first code line, remove the complete code and replace it with the following code:

<%@ Register Assembly="TXTextControl.Web" Namespace="TXTextControl.Web" TagPrefix="cc1" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <cc1:TextControl ID="TextControl1" runat="server" />

    <input type="button" onclick="insertTable()" value="Insert Table" />

    <script>
        function insertTable() {
            TXTextControl.tables.add(5, 5, 10, function(e) {
              if (e === true) { // if added
                TXTextControl.tables.getItem(function(table) {
                  table.cells.forEach(function(cell) {

                    cell.setText("Cell text");

                  });
                }, null, 10);
              }
            })
        }
    </script>

</asp:Content>

2. Find the Web.config file in the project's root folder and add the following entry after the opening configuration element:

<system.webServer>
  <handlers>
    <add name="TXWebSocketHandler" verb="*" path="TXWebSocketHandler.ashx" type="TXTextControl.Web.WebSocketHandler, TXTextControl.Web, Version=31.0.1100.500, Culture=neutral, PublicKeyToken=6B83FE9A75CFB638" />
    <add name="TXPrintHandler" verb="*" path="TXPrintHandler.ashx" type="TXTextControl.Web.TXPrintHandler, TXTextControl.Web, Version=31.0.1100.500, Culture=neutral, PublicKeyToken=6B83FE9A75CFB638" />
  </handlers>
</system.webServer>

Compile and start the application.