WebControl.ForeColor 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 Web 服务器控件的前景色(通常是文本颜色)。
public:
virtual property System::Drawing::Color ForeColor { System::Drawing::Color get(); void set(System::Drawing::Color value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
public virtual System.Drawing.Color ForeColor { get; set; }
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
public virtual System.Drawing.Color ForeColor { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))>]
member this.ForeColor : System.Drawing.Color with get, set
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))>]
member this.ForeColor : System.Drawing.Color with get, set
Public Overridable Property ForeColor As Color
属性值
- 属性
示例
下面的示例演示如何设置 ForeColor 从基类继承的 Table 控件的 WebControl 属性。
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Table Property</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>Property of a Table Web Control</h3>
<asp:Table id="Table1" runat="server"
CellPadding = "10"
CellSpacing="0"
GridLines="Both"
Font-Bold="true"
ForeColor="Red">
<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>
</div>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Table Property</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>Property of a Table Web Control</h3>
<asp:Table id="Table1" runat="server"
CellPadding = "10"
CellSpacing="0"
GridLines="Both"
Font-Bold="true"
ForeColor="Red">
<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>
</div>
</form>
</body>
</html>
注解
ForeColor使用 属性指定 Web 服务器控件的前景色。 前景色通常是文本的颜色。 对于除 、 AdRotatorHyperLink 和 LinkButton之外的所有控件,此属性将在早于 Microsoft Internet Explorer 版本 4 的Image浏览器中呈现。
注意
在早于 Microsoft Internet Explorer 版本 4 的浏览器中,此属性呈现为 <font>
标记。