Asp. How to use literal controls in net [Original]_ Foundation Application

Source: Internet
Author: User

You can use the Literal control as a container for other content on a Web page. The Literal control is most commonly used to dynamically add content to a Web page. Simply put, the HTML code can be written to the Literal control and presented directly.

First, common literal properties

Property Description
Text Specifies the text to display in the Literal control. In the user's browser, this will appear as HTML.
Mode Specifies how the control handles the markup that is added to it.

Ii. Basic Usage

Front desk literaltest.aspx

Copy Code code as follows:

<asp:literal id= "Literal1" runat= "Server" ></asp:Literal>

Backstage LiteralTest.aspx.cs

Copy Code code as follows:

protected void Page_Load (object sender, EventArgs e)
{
string table = "<table cellspacing=\" 0\ "cellpadding=\ 3\" border=\ "1\" ><tr><td style=\ "border:1px;\" >hello world</td></tr></table> ";
This. Literal1.text = table;
}

Three, literal and label difference

A 1.Literal control is similar to a Label control, but the Literal control does not allow styles to be applied to the displayed text. You can programmatically control the text that is displayed in the control by setting the Text property.

The 2.Literal control does not produce any extra HTML code, and the label control generates a span label.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.