ASP.NET MVC: How to Use the HtmlHelper Settings with Lambda Expressions
The MVC version of TXTextControl.Web provides an HtmlHelper to support the rendering of the HTML5-based editor in a view. In the HtmlHelper, all properties can be adjusted and methods can be called to load documents or to load a database. In order to render the default view of TXTextControl.Web, the following simple razor code is required: In order to set properties of the TXTextControl.Web object, lambda expressions can be used. The following razor code shows how to set several properties…

The MVC version of TXTextControl.Web provides an HtmlHelper to support the rendering of the HTML5-based editor in a view.
In the HtmlHelper, all properties can be adjusted and methods can be called to load documents or to load a database. In order to render the default view of TXTextControl.Web, the following simple razor code is required:
@using TXTextControl.Web
@using TXTextControl.Web.MVC
@Html.TXTextControl().TextControl().Render()
In order to set properties of the TXTextControl.Web object, lambda expressions can be used. The following razor code shows how to set several properties that will be applied automatically when rendering the control:
@Html.TXTextControl().TextControl(settings =>
{
settings.DocumentTargetMarkers = true;
settings.DocumentFileDirectory = Server.MapPath("~/App_Data/Documents");
settings.TableGridLines = false;
settings.StatusBarColor = System.Drawing.Color.Red;
settings.BackColor = System.Drawing.Color.Yellow;
settings.Dock = TXTextControl.Web.DockStyle.Window;
}).Render()
Additionally, methods can be called in the HtmlHelper. The following code snippet loads a document and loads an XML database for the Reports ribbon tab:
@Html.TXTextControl().TextControl(settings =>
{
settings.Dock = TXTextControl.Web.DockStyle.Window;
}).LoadText(Server.MapPath("~/App_Data/Documents/invoice.docx"),
StreamType.WordprocessingML).LoadXMLDatabase(
Server.MapPath("~/App_Data/DataSources/sample_db.xml")).Render()
Related Posts
ASP.NETJavaScriptDocument Editor
Detect Toggle Button Changes Using a MutationObserver
This article shows how to detect changes of toggle buttons in the ribbon of the web editor using a MutationObserver. The state of a toggle button in the ribbon visualizes the state of a certain…
Implementing Conditional Table Cell Colors with MailMerge
This ASP.NET MVC sample shows how to implement conditional table cell colors using the online document editor and an ASP.NET backend.
Deploying the MVC HTML5 Editor to Azure App Services
This article describes how to deploy the ASP.NET MVC HTML5 editor to Azure App Services.
Sneak Peek X15: Copy to Local Clipboard Support in ASP.NET Version
The HTML5 based editor for ASP.NET MVC and Web Forms (AJAX) provides access to two different clipboards: The server-side clipboard uses the internal TX Text Control format and allows to copy and…
Sneak Peek X15: Custom Field Overlays in HTML5-based Text Control
A highly requested feature for our HTML5-based Web.TextControl is the ability to show field overlays or custom elements such as HTML form elements on top of all types of fields. In version X15,…