Professional Documents
Culture Documents
DISPLAY Label literal INPUT Textbox RadioButton CheckBox FORM SUBMISSION CONTROLS Button LinkButton ImageButton Using Client scripts with Button controls IMAGE Image ImageMap PANEL HYPERLINK CONTROLS
DISPLAY CONTROLS
The ASP.NET Framework includes two controls you can use to display text in a page: the Label control and the Literal control. Whereas the Literal control simply displays text, the Label control supports several additional formatting properties.
[2]Literal
You can use the Literal control to display text or HTML content in a browser. However, unlike the Label control, the Literal control does not render its content inside of a <span> tag.
[1] Label
Whenever you need to modify the text displayed in a page dynamically, you can use the Label control. <%@ Page Language=C# %> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <script runat=server> void Page_Load() { lblTime.Text = DateTime.Now.ToString(T); } </script> <html xmlns=http://www.w3.org/1999/xhtml > <head id=Head1 runat=server> <title>Show Label</title> </head> <body> <form id=form1 runat=server> <div> <asp:Label id=lblTime Runat=server /> </div> </form> </body> </html>
The Label control supports several properties you can use to format the text displayed by the Label (this is not a complete list):
the Label (this is not a complete list): . BackColorEnables you to change the background color of the label. . BorderColorEnables you to set the color of a border rendered around the label. . The Label control supports several properties you can use to format the text displayed by the Label (this is not a complete list): . BackColorEnables you to change the background color of the label. . BorderColorEnables you to set the color of a border rendered around the label. . BorderStyleEnables you to display a border around the label. Possible values are NotSet, None, Dotted, Dashed, Solid, Double, Groove, Ridge, Inset, and Outset. . BorderWidthEnables you to set the size of a border rendered around the label. . CssClassEnables you to associate a Cascading Style Sheet class with the label. . FontEnables you to set the labels font properties. . ForeColorEnables you to set the color of the content rendered by the label. . StyleEnables you to assign style attributes to the label. . ToolTipEnables you to set a labels title attribute. (In Microsoft Internet Explorer, the title attribute is displayed as a floating tooltip.) Enables you to display a border around the label. Possible values are NotSet, None, Dotted, Dashed, Solid, Double, Groove, Ridge, Inset, and Outset.