WebControl.Font 속성

정의

웹 서버 컨트롤과 연결된 글꼴 속성을 가져옵니다.

public:
 virtual property System::Web::UI::WebControls::FontInfo ^ Font { System::Web::UI::WebControls::FontInfo ^ get(); };
public virtual System.Web.UI.WebControls.FontInfo Font { get; }
member this.Font : System.Web.UI.WebControls.FontInfo
Public Overridable ReadOnly Property Font As FontInfo

속성 값

FontInfo

웹 서버 컨트롤의 글꼴 속성을 나타내는 FontInfo입니다.

예제

다음 예제를 사용 하는 방법을 합니다 Font 에서 글꼴 정보를 수집 하는 속성을 Label 제어 합니다.

참고

다음 코드 샘플 단일 파일 코드 모델을 사용 하 고 코드 숨김 파일에 직접 복사 하는 경우 제대로 작동 하지 않을 수 있습니다. 이 코드 샘플.aspx 확장명이 있는 빈 텍스트 파일에 복사 해야 합니다. Web Forms 코드 모델에 대 한 자세한 내용은 참조 하세요. ASP.NET Web Forms 페이지 코드 모델합니다.

<%@ 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 Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "The current font is: " + Label1.Font.ToString();
        }

        void Button2_Click(object sender, EventArgs e)
        {
            Label1.Font.Underline = !Label1.Font.Underline;
            if (Label1.Font.Name == "Verdana")
                Label1.Font.Name = "Times";
            else
                Label1.Font.Name = "Verdana";
        }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Enabled Property Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>FontUnit Property of a Web Control</h3>
        <asp:Label id="Label1" runat="server"
            Font-Names="Verdana" Font-Size="10pt"
            Text="This is a Label control." />  
 
            <p>
            <asp:Button id="Button1" runat="server"
                Text="Click to display font info"
                OnClick="Button1_Click" Width="300px" />
            </p>
 
            <p>
            <asp:Button id="Button2" runat="server"
                Text="Click to change font and underlining"
                OnClick="Button2_Click" Width="300px" />
            </p>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Label1.Text = "The current font is: " & Label1.Font.ToString()
    End Sub

    Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
        Label1.Font.Underline = Not Label1.Font.Underline
        If Label1.Font.Name = "Verdana" Then
            Label1.Font.Name = "Times"
        Else
            Label1.Font.Name = "Verdana"
        End If
            
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Enabled Property Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>FontUnit Property of a Web Control</h3>
        <asp:Label id="Label1" runat="server"
            Font-Names="Verdana" Font-Size="10pt"
            Text="This is a Label control." />  
 
            <p>
            <asp:Button id="Button1" runat="server"
                Text="Click to display font info"
                OnClick="Button1_Click" Width="300px" />
            </p>
 
            <p>
            <asp:Button id="Button2" runat="server"
                Text="Click to change font and underlining"
                OnClick="Button2_Click" Width="300px" />
            </p>
    </div>
    </form>
</body>
</html>

설명

사용 된 Font 속성을 통해 웹 서버 컨트롤의 글꼴 속성을 지정 합니다. 이 속성에 액세스할 수 있는 하위 선언적으로 형태로 Property-Subproperty (예를 들어 Font-Bold) 또는 프로그래밍 방식으로 형태로 Property.Subproperty (예를 들어 Font.Bold).

하나를 제외한 모든 하위 속성은 Microsoft Internet Explorer 버전 4 모든 컨트롤에 대 한 이전 브라우저에서 렌더링 됩니다. 이들은: Bold, Italic, Name, Names, StrikeoutUnderline, 및 Size (만 글꼴 크기와 같은 이름이 Small, Smaller등, 작동).

참고

이러한 하위 속성은 Microsoft Internet Explorer 버전 4 이전 브라우저에서 렌더링, 있지만 렌더링 되는 HTML 이상 브라우저와 다릅니다. 스타일 특성으로 렌더링 하는 대신 이러한 하위 속성으로 렌더링 됩니다 HTML 요소와 같은 <b><font>입니다.

모든 컨트롤에 대 한 이전 브라우저에서 렌더링 되지 않는 한 하위 속성은 Overline합니다.

적용 대상

추가 정보