Поделиться через


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>

This allows you to quickly display a chunk of HTML in a form in an ASP.NET mobile Web page.

You can use a limited number of formatting elements inside form markup, as listed in the following table:

Element 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 at run time. Note that at design time, unsupported tags in literal text can cause undesirable results when the page is edited in Visual Studio.

The tags used in literal text do not necessarily correspond to tags in the output. For example, <p> tags might be translated into <br> tags by a control adapter. In addition, because controls themselves can cause line breaks, line breaks that exist as the only literal text between two controls are ignored. To force a break between two controls, you can insert a non-breaking space (&nbsp;) between the controls, in addition to the appropriate break.

When nesting tags, the hyperlink 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.

During compilation, 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 page's control tree. (The control tree is the tree of controls on a page — the page itself, its child controls, their children, and so on.) 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.

NoteNote

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

See Also

Reference

LiteralText

Other Resources

Application Developer's Guide
Developing ASP.NET Mobile Web Pages