IStyleSheet 인터페이스

정의

스타일 규칙 작성을 지원하기 위해 클래스에서 구현해야 하는 메서드를 정의합니다.

public interface class IStyleSheet
public interface IStyleSheet
type IStyleSheet = interface
Public Interface IStyleSheet

예제

다음 코드 예제에서는 합니다 Header 구현의 IStyleSheet 프로그래밍 방식으로 새 스타일 규칙 만들기 및 사용자 지정 등록을 보여 주기 위해 Style 개체입니다.

예제에서는 사용자 지정의 1 부에서 Style 개체를 labelStyle가 만들어지고 다음 현재 위치 (URL)에 등록 합니다. 해당 label1 호출 레이블을 합니다 MergeStyle 메서드 있도록를 labelStyle 스타일을 적용할를 label1 레이블.

다른 사용자 지정을 정의 하는 예제의 두 번째 부분은 Style 개체를 bodyStyle, 새 스타일 규칙을 만들려면 해당 속성을 설정 합니다.

참고

이 클래스는 주로 사용자 지정 구현의 만들려는 개발자를 위한 것입니다. 이 예제에서는.NET Framework에서 제공 되는 구현을 보여 줍니다.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="istylesheetcs.aspx.cs" Inherits="istylesheetcs" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
    <title>IStyleSheet Example</title>
</head>    
<body>
    <form id="form1" runat="server">
        <h1>IStyleSheet Example</h1>
        <asp:Label 
          id="label1" 
          runat="server">
        </asp:Label>
        <br /><br />
        <asp:Label 
          id="label2" 
          runat="server">
        </asp:Label>
    </form>
  </body>
</html>
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="istylesheetvb.aspx.vb" Inherits="istylesheetvb" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
    <title>IStyleSheet Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <h1>IStyleSheet Example</h1>
        <asp:Label 
          id="label1" 
          runat="server">
        </asp:Label>
        <br /><br />
        <asp:Label 
          id="label2" 
          runat="server">
        </asp:Label>
    </form>
  </body>
</html>

다음은 앞의 예제에서 웹 페이지에 대 한 코드 숨김 파일입니다.

public partial class istylesheetcs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Create a Style object to hold style rules to apply to a Label control.
        Style labelStyle = new Style();

        labelStyle.ForeColor = System.Drawing.Color.DarkRed;
        labelStyle.BorderColor = System.Drawing.Color.DarkBlue;
        labelStyle.BorderWidth = 2;

        // Register the Style object so that it can be merged with 
        // the Style object of the controls that use it.
        Page.Header.StyleSheet.RegisterStyle(labelStyle, null);

        // Merge the labelCssStyle style with the label1 control's
        // style settings.
        label1.MergeStyle(labelStyle);
        label1.Text = "This is what the labelCssStyle looks like.";

        // Create a Style object for the <BODY> section of the Web page.
        Style bodyStyle = new Style();

        bodyStyle.ForeColor = System.Drawing.Color.Blue;
        bodyStyle.BackColor = System.Drawing.Color.LightGray;

        // Add the style to the header of the current page.
        Page.Header.StyleSheet.CreateStyleRule(bodyStyle, null, "BODY");

        // Add text to the label2 control to see the label without 
        // the labelStyle applied to it.  
        label2.Text = "This is what the bodyStyle looks like.";
    }
}

설명

이 인터페이스를 구현 하는 클래스 스타일 규칙 만들기를 지원 하는 데 사용할 수 있습니다.

스타일 시트를 생성 및 등록 방법을 사용자 지정 하려면이 인터페이스를 구현 하는 클래스를 만들어야 합니다.

합니다 HtmlHead 클래스를 통해 ASP.NET에서 사용 하기 위해이 인터페이스를 구현 합니다 Header 속성입니다.

참고

비동기 포스트백 도중 스타일 또는 스타일 규칙을 프로그래밍 방식으로 수정 또는 추가 지원 되지 않습니다. ASP.NET 웹 페이지에 AJAX 기능을 추가 하면 비동기 포스트백 전체 페이지를 업데이트 하지 않고 페이지의 영역을 업데이트 합니다. 자세한 내용은 Microsoft Ajax Overview합니다.

메서드

CreateStyleRule(Style, IUrlResolutionService, String)

클래스에서 구현할 때 지정한 문서 언어 요소 형식 또는 선택기에 대한 스타일 규칙을 만듭니다.

RegisterStyle(Style, IUrlResolutionService)

클래스에서 구현할 때 웹 페이지의 <head> 섹션에 있는 포함 스타일시트에 새 스타일 규칙을 추가합니다.

적용 대상

추가 정보