IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
A TextField is a field control used to edit and display text values. Wherever you have a Title, Name or similar property, you can use a TextField.
TextField in Write mode, used in the backend form for creating News.
TextField in Read mode, used in the widget template for the News widget.
Whenever you are developing a static module, your persistent model is implemented as a class in C# or VB. In this case, fields are normal properties in that class. To make up the user interface of your module, we recommend using definitions. For an example of implementing those definitions, you can read Custom Products module: Create the backend definitions.
To use TextField in a static module, you should use the following code in the definitions of your module:
var titleField =
new
TextFieldDefinitionElement(mainSection.Fields)
{
ID =
"titleFieldControl"
,
DataFieldName = (displayMode == FieldDisplayMode.Write) ?
"Title.PersistedValue"
:
"Title"
DisplayMode = displayMode,
Title =
"lTitle"
CssClass =
"sfTitleField"
ResourceClassId =
typeof
(ProductsResources).Name,
WrapperTag = HtmlTextWriterTag.Li,
};
mainSection.Fields.Add(titleField);
In the code above, you just create a new TextFieldDefinitionElement and add it to the section. The DataFieldName property should be the name of the property in your persistent class, which will contain the value. If you are localizing all your labels for the module, you should also set the ResourceClassID property, as the example does with ProductsResources.
You can also use TextField in a custom field that you create through the user interface. You can do that in the built-in Sitefinity CMS modules (static and dynamic), as well as in your custom modules. When you are creating the custom field through the UI, you should specify a custom widget for entering data. The type that you need to use is Telerik.Sitefinity.Web.UI.Fields.TextField.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important