Products Technologies Demo Docs Blog Support Company

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

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

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

The following tutorial shows how to create an ASP.NET (Framework) web application that uses the Document Editor.

Prerequisites

There are two ways to evaluate the TX Text Control Document Editor. You can either host your own backend by downloading the trial version of TX Text Control .NET Server, or by creating a trial access token to use a hosted backend, valid for 30 days:

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 MVC as the project template, check Web API from the Add folders & core references selection and confirm with Create.

    Creating the .NET 6 project

Adding the NuGet Package

  1. In the Solution Explorer, select your created project and choose Manage NuGet Packages... from the Project main menu.

    Package Source

    Select either Text Control Offline Packages or nuget.org as the Package source. Packages in the official Text Control NuGet profile are frequently updated.

    In case you are using a Trial Access Token, please choose nuget.org.

    Browse for txtextcontrol.web and Install the latest version of the TXTextControl.Web package.

    ASP.NET Core Web Application

Adding the Control to the View

  1. Find the Index.cshtml file in the Views -> Home folder. Replace the complete content with the following code to add the document editor to the view:

    @using TXTextControl.Web.MVC
        
    @{
        var sDocument = "<html><body><p>Welcome to <strong>Text Control</strong></p></body></html>";
    }
    
    @Html.TXTextControl().TextControl(settings => {
        settings.UserNames = new string[] { "Tim Typer" };
    }).LoadText(sDocument, TXTextControl.Web.StringStreamType.HTMLFormat).Render()
    
    <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>

    Trial Access Token Users

    In case you are using a Trial Access Token, replace the content with the following code.

    Replace addYourTokenHere with your actual Trial Access Token.

Compile and start the application.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

ASP.NETGetting StartedMVC

Getting Started: Document Viewer with ASP.NET MVC (.NET Framework)

This article shows how to use the TX Text Control ASP.NET document viewer within a .NET Framework web application in Visual Studio 2022.


ASP.NETASP.NET CoreGetting Started

Getting Started: Document Editor with ASP.NET Core

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


ASP.NETASP.NET Web FormsGetting Started

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.


ASP.NETMailMergeMVC

Getting Started: ServerTextControl and MailMerge with ASP.NET MVC (.NET…

This article shows how to use the TX Text Control ASP.NET ServerTextControl and MailMerge classes within an ASP.NET web application in Visual Studio 2022.


ASP.NETASP.NET CoreGetting Started

Getting Started: Document Editor with ASP.NET Core

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