©
This document uses PHP Chinese website manual Release
ForeColor 属性用于设置或返回控件的前景颜色(通常是文本的颜色)。
<asp:webcontrol id="id" ForeColor="color" runat="server" />
属性 | 描述 |
---|---|
color | 设置为控件的前景颜色的颜色。必须是合法的 HTML 颜色。 |
下面的实例设置了按钮的前景颜色:
<form runat="server">
<asp:Button id="button1" Text="Submit"
ForeColor="#FF0000" runat="server" />
</form>
设置 Button 控件的文本颜色(带有声明和脚本)
<%@ Import Namespace="System.Drawing" %> <!DOCTYPE html> <html> <head> <script runat="server"> Sub ChangeForeColor(obj As Object, e As EventArgs) button1.ForeColor = Color.FromName("Red") End Sub </script> </head> <body> <form runat="server"> <asp:Button id="button1" runat="server" ForeColor="#0000FF" Text="Change" OnClick="ChangeForeColor" /> </form> </body> </html>