Share via


Literal Text Inside Form Markup

For ASP.NET mobile controls, the term literal text refers to the text that is placed directly in a Form, Panel, or TextView mobile control. The following example shows text placed directly in a Form control.

<mobile:Form>This is literal text.</mobile:Form>

Although you can place literal text inside form markup, the ASP.NET mobile controls technology does not recognize all tags. The following table lists all the HTML tags that mobile controls recognize.

Tag Description
<a> Converts inner text to a hyperlink. The hyperlink text cannot contain other formatting tags.
<b> Converts inner text to a bold style.
<br> Breaks to a new line.
<i> Converts inner text to an italic style.
<p> Begins a new paragraph or, when used with a closing tag, places inner text in a separate paragraph.

Other tags are ignored. This allows you to quickly display a chunk of HTML in a form in an ASP.NET mobile Web application. Inserting unsupported tags in literal text can cause undesirable results when the page is edited in the ASP.NET Mobile Designer.

The tags used in literal text do not necessarily correspond to tags in the output. For example, <p> tags may be translated into <br> tags. Also, because controls themselves cause breaks, breaks that exist as the only literal text between two controls are ignored. To force a break between two controls, the developer can insert a nonbreaking space (&nbsp;) between the controls, in addition to the appropriate break.

When nesting tags, the hyperlink tag (anchor tag: <a>) does not recognize nested tags. For example, nesting the <b> or <i> tag as literal text inside the <a> tag does not render a link as bold or italic. The control completely ignores all tags inside of the <a> tag.

ASP.NET automatically creates LiteralText controls from static text, as needed. At compile time, literal text is translated into LiteralText and Link controls. Because the text is static, these controls are not intended to be addressable, although they still appear in the control tree. (The control tree is the tree of controls on a page — the page itself, its child controls, their children, and so on.) After they are created, LiteralText controls are placed in the control tree. Thus, if you are programmatically enumerating the child controls of a form, you might find a LiteralText control, even though you did not explicitly add one to your page.

Note   Place a <br> tag in footer templates to ensure that the footer template contents do not appear inline with the page.

See Also

LiteralText Class | Application Developer's Guide | Developing ASP.NET Mobile Web Applications