Share via


TextView Control

The TextView control displays arbitrary amounts of text, with optional markup tags. The format of the text in a TextView control is identical to that in literal text on a form. However, unlike literal text on a form, you can set the text in a TextView control. The TextView control supports internal pagination. For more information, see the Pagination documentation.

Mobile Controls Syntax

Required properties, defaults, and code-featured elements are noted in bold type.

<mobile:TextView
   runat="server"
   id="id"
   Font-Name="fontName"
   Font-Size="{NotSet|Normal|Small|Large}"
   Font-Bold="{NotSet|False|True}"
   Font-Italic="{NotSet|False|True}"
   ForeColor="foregroundColor"
   BackColor="backgroundColor"
   Alignment="{NotSet|Left|Center|Right}"
   StyleReference="styleReference"
   Wrapping="{NotSet|Wrap|NoWrap}"

   Text="Text">
   [TextViewElement]*</mobile:TextView>

Containment Rules

The following controls can contain a TextView control.

Control Comments
System.Web.UI.MobileControls.Form Can contain any number of TextView controls.
System.Web.UI.MobileControls.Panel Can contain any number of TextView controls.

A TextView control cannot contain any other controls.

Device Templates

None.

Device-Specific Behavior

The style with which literal text is rendered will differ based on device, but the literal text will appear on all devices. The text is rendered in the same way in HTML and WML.

The control renders literal text on its own line with the appropriate style attributes applied. However, the LiteralText control differs from the Label control in that it provides the option of not using the <br> tag (line break) that usually follows a label.

For more information about how the different style attributes are interpreted on different devices, see the Device-Specific Rendering documentation.

Example

The following example shows a single form with one TextView control and demonstrates setting some of the properties of the TextView control at design-time.

[Visual Basic, C#]
<%@ Page Inherits=
   "System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
    Namespace="System.Web.UI.MobileControls"
    Assembly="System.Web.Mobile" %>

<mobile:Form id="Form1" runat="server">
   <mobile:TextView id="TextView1" StyleReference="title"
      ForeColor="Blue" runat="server">
      This is a TextView control.
   </mobile:TextView>
</mobile:Form>

See Also

TextView Class | TextView Class Members | TextViewElement Class | Control Reference