Export (0) Print
Expand All

WebControl.ForeColor Property

Gets or sets the foreground color (typically the color of the text) of the Web server control.

[Visual Basic]
Public Overridable Property ForeColor As Color
[C#]
public virtual Color ForeColor {get; set;}
[C++]
public: __property virtual Color get_ForeColor();
public: __property virtual void set_ForeColor(Color);
[JScript]
public function get ForeColor() : Color;
public function set ForeColor(Color);

Property Value

A System.Drawing.Color that represents the foreground color of the control. The default is Color.Empty.

Remarks

Use the ForeColor property to specify the foreground color of the Web server control. The foreground color is usually the color of the text. This property will render on browsers earlier than Microsoft Internet Explorer version 4 for all controls, except the Image, AdRotator, HyperLink and LinkButton.

Note   On browsers earlier than Microsoft Internet Explorer version 4, this property is rendered as <font> tags.

Example

[Visual Basic, C#, JScript] The following example illustrates how to set the ForeColor property of the Table control, inherited from the WebControl base class.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
 <body>
     <h3>ForeColor Property of a Web Control</h3>
 
 <form runat=server>
 
 <asp:Table id="Table1" runat="server"
    CellPadding=10 
    GridLines="Both"
    
    ForeColor="Blue"
 >
 
    <asp:TableRow>
       <asp:TableCell>
          Row 0, Col 0
       </asp:TableCell>
 
       <asp:TableCell>
          Row 0, Col 1
       </asp:TableCell>
    </asp:TableRow>
 
    <asp:TableRow>
       <asp:TableCell>
          Row 1, Col 0
       </asp:TableCell>
 
       <asp:TableCell>
          Row 1, Col 1
       </asp:TableCell>
    </asp:TableRow>
 
 </asp:Table>
 
 </form>
 
 </body>
 </html>
 

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
 <body>
     <h3>ForeColor Property of a Web Control</h3>
 
 <form runat=server>
 
 <asp:Table id="Table1" runat="server"
    CellPadding=10 
    GridLines="Both"
    
    ForeColor="Blue"
 >
 
    <asp:TableRow>
       <asp:TableCell>
          Row 0, Col 0
       </asp:TableCell>
 
       <asp:TableCell>
          Row 0, Col 1
       </asp:TableCell>
    </asp:TableRow>
 
    <asp:TableRow>
       <asp:TableCell>
          Row 1, Col 0
       </asp:TableCell>
 
       <asp:TableCell>
          Row 1, Col 1
       </asp:TableCell>
    </asp:TableRow>
 
 </asp:Table>
 
 </form>
 
 </body>
 </html>
 

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
 <body>
     <h3>ForeColor Property of a Web Control</h3>
 
 <form runat=server>
 
 <asp:Table id="Table1" runat="server"
    CellPadding=10 
    GridLines="Both"
    ForeColor="Blue"
 >
 
    <asp:TableRow>
       <asp:TableCell>
          Row 0, Col 0
       </asp:TableCell>
 
       <asp:TableCell>
          Row 0, Col 1
       </asp:TableCell>
    </asp:TableRow>
 
    <asp:TableRow>
       <asp:TableCell>
          Row 1, Col 0
       </asp:TableCell>
 
       <asp:TableCell>
          Row 1, Col 1
       </asp:TableCell>
    </asp:TableRow>
 
 </asp:Table>
 
 </form>
 
 </body>
 </html>
 

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

WebControl Class | WebControl Members | System.Web.UI.WebControls Namespace | Style | System.Drawing.Color

Show:
© 2014 Microsoft