EditorPartChrome 클래스

정의

개발자가 EditorPart 영역에서 EditorZoneBase 컨트롤의 선택된 섹션에 대해서만 렌더링을 재정의할 수 있도록 합니다.

public ref class EditorPartChrome
public class EditorPartChrome
type EditorPartChrome = class
Public Class EditorPartChrome
상속
EditorPartChrome

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 EditorPartChrome 클래스의 기본 렌더링을 재정의할 EditorPart 컨트롤는 EditorZoneBase 영역입니다.

이 코드 예제는 세 부분으로 구성 합니다.

  • 웹 파트 페이지의 디스플레이 모드를 변경할 수 있게 해 주는 사용자 정의 컨트롤입니다.

  • 예제에서 모든 컨트롤을 호스팅하는 웹 페이지입니다.

  • 사용자 지정에 대 한 소스 코드를 포함 하는 클래스 EditorPartChrome 클래스 및 EditorZoneBase 영역입니다.

코드 예제의 첫 번째 부분은 사용자 정의 컨트롤입니다. 사용자 정의 컨트롤에 대 한 소스 코드는 다른 항목에서 제공 됩니다. 작동 하려면이 코드 예제에서는 사용자 컨트롤은.ascx 파일을 가져올 필요가 합니다 연습: 웹 파트 페이지의 디스플레이 모드를 변경 항목 및이 코드 예제에서.aspx 페이지와 같은 폴더에 파일 위치입니다.

예제의 두 번째 부분은 웹 페이지입니다. 한 Register 컴파일된 구성 요소 및 태그 접두사를 등록할 파일의 위쪽에 지시문입니다. 페이지 요소를 사용 하는 사용자 지정 편집기 영역을 참조 하는지 참고 <aspSample:MyEditorZone>합니다.

<%@ Page Language="C#" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.CS.Controls" %>
<%@ Register TagPrefix="uc1" TagName="DisplayModeMenuCS" Src="~/DisplayModeMenuCS.ascx" %>
<!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>Web Parts Page</title>
</head>
<body>
  <h1>Web Parts Demonstration Page</h1>
  <form runat="server" id="form1">
<asp:webpartmanager id="WebPartManager1" runat="server" />
<uc1:DisplayModeMenuCS runat="server" ID="DisplayModeMenu" />
  <br />
  <table cellspacing="0" cellpadding="0" border="0">
    <tr>
      <td valign="top">
    <asp:webpartzone id="SideBarZone" runat="server" 
        headertext="Sidebar">
        <zonetemplate>
        </zonetemplate>
      </asp:webpartzone>
      <aspSample:MyEditorZone ID="EditorZone1" runat="server">
      <ZoneTemplate>
        <asp:AppearanceEditorPart ID="AppearanceEditorPart1" 
          runat="server" />
        <asp:LayoutEditorPart ID="LayoutEditorPart1" 
          runat="server" />
      </ZoneTemplate>
    </aspSample:MyEditorZone>
      </td>
      <td valign="top">
    <asp:webpartzone id="MainZone" runat="server" headertext="Main">
         <zonetemplate>
        <asp:label id="contentPart" runat="server" title="Content">
              <h2>Welcome to My Home Page</h2>
              <p>Use links to visit my favorite sites!</p>
            </asp:label>
         </zonetemplate>
       </asp:webpartzone>
      </td>
      <td valign="top">
      </td>
    </tr>
  </table>
  </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.VB.Controls" %>
<%@ Register TagPrefix="uc1" TagName="DisplayModeMenuVB" Src="~/DisplayModeMenuVB.ascx" %>
<!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>Web Parts Page</title>
</head>
<body>
  <h1>Web Parts Demonstration Page</h1>
  <form runat="server" id="form1">
<asp:webpartmanager id="WebPartManager1" runat="server" />
<uc1:DisplayModeMenuVB runat="server" ID="DisplayModeMenu" />
  <br />
  <table cellspacing="0" cellpadding="0" border="0">
    <tr>
      <td valign="top">
    <asp:webpartzone id="SideBarZone" runat="server" 
        headertext="Sidebar">
        <zonetemplate>
        </zonetemplate>
      </asp:webpartzone>
      <aspSample:MyEditorZone ID="EditorZone1" runat="server">
      <ZoneTemplate>
        <asp:AppearanceEditorPart ID="AppearanceEditorPart1" 
          runat="server" />
        <asp:LayoutEditorPart ID="LayoutEditorPart1" 
          runat="server" />
      </ZoneTemplate>
    </aspSample:MyEditorZone>
      </td>
      <td valign="top">
    <asp:webpartzone id="MainZone" runat="server" headertext="Main">
         <zonetemplate>
        <asp:label id="contentPart" runat="server" title="Content">
              <h2>Welcome to My Home Page</h2>
              <p>Use links to visit my favorite sites!</p>
            </asp:label>
         </zonetemplate>
       </asp:webpartzone>
      </td>
      <td valign="top">
      </td>
    </tr>
  </table>
  </form>
</body>
</html>

사용자 지정 편집기 파트 chrome 및 편집기 파트 영역의 구현을 포함 하는 예제에서는 세 번째 부분입니다. MyEditorZone 확장 EditorZone 재정의 및 CreateEditorPartChrome 파트 chrome 사용자 지정 편집기를 반환 합니다. MyEditorPartChrome 편집기 파트 컨트롤의 배경색을 변경 합니다 CreateEditorPartChromeStyle 메서드. 영역의 배경 색상에서 변경 되는 PerformPreRender 메서드 및 텍스트 편집기 부분에 추가 됩니다는 RenderPartContents 메서드.

namespace Samples.AspNet.CS.Controls
{

    [AspNetHostingPermission(SecurityAction.Demand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyEditorPartChrome : EditorPartChrome
    {
        public MyEditorPartChrome(EditorZoneBase zone)
            : base(zone)
        {
        }
        
        protected override Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType)
        {
            Style editorStyle = base.CreateEditorPartChromeStyle(editorPart, chromeType);
            editorStyle.BackColor = Color.Bisque;
            return editorStyle;
        }

        public override void PerformPreRender()
        {
            Style zoneStyle = new Style();
            zoneStyle.BackColor = Color.Cornsilk;

            Zone.Page.Header.StyleSheet.RegisterStyle(zoneStyle, null);
            Zone.MergeStyle(zoneStyle);
        }

        protected override void RenderPartContents(HtmlTextWriter writer, EditorPart editorPart)
        {
            writer.AddStyleAttribute("color", "red");
            writer.RenderBeginTag("p");
            writer.Write("Apply all changes");
            writer.RenderEndTag();
            editorPart.RenderControl(writer);
        }

        public override void RenderEditorPart(HtmlTextWriter writer, EditorPart editorPart)
        {
            base.RenderEditorPart(writer, editorPart);
        }
    }

    [AspNetHostingPermission(SecurityAction.Demand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyEditorZone : EditorZone
    {
        protected override EditorPartChrome CreateEditorPartChrome()
        {
            return new MyEditorPartChrome(this);
        }
    }
}
Namespace Samples.AspNet.VB.Controls


    <AspNetHostingPermission(SecurityAction.Demand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class MyEditorPartChrome
        Inherits EditorPartChrome

        Public Sub New(ByVal zone As EditorZoneBase)
            MyBase.New(zone)
        End Sub

        Protected Overrides Function CreateEditorPartChromeStyle(ByVal editorPart As System.Web.UI.WebControls.WebParts.EditorPart, ByVal chromeType As System.Web.UI.WebControls.WebParts.PartChromeType) As System.Web.UI.WebControls.Style
            Dim editorStyle As Style
            editorStyle = MyBase.CreateEditorPartChromeStyle(editorPart, chromeType)
            editorStyle.BackColor = Drawing.Color.Bisque
            Return editorStyle
        End Function

        Public Overrides Sub PerformPreRender()
            Dim zoneStyle As Style = New Style
            zoneStyle.BackColor = Drawing.Color.Cornsilk

            Zone.Page.Header.StyleSheet.RegisterStyle(zoneStyle, Nothing)
            Zone.MergeStyle(zoneStyle)
        End Sub

        Protected Overrides Sub RenderPartContents(ByVal writer As System.Web.UI.HtmlTextWriter, ByVal editorPart As System.Web.UI.WebControls.WebParts.EditorPart)
            writer.AddStyleAttribute("color", "red")
            writer.RenderBeginTag("p")
            writer.Write("Apply all changes")
            writer.RenderEndTag()
            editorPart.RenderControl(writer)
        End Sub

        Public Overrides Sub RenderEditorPart(ByVal writer As System.Web.UI.HtmlTextWriter, ByVal editorPart As System.Web.UI.WebControls.WebParts.EditorPart)
            MyBase.RenderEditorPart(writer, editorPart)
        End Sub
    End Class


    <AspNetHostingPermission(SecurityAction.Demand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class MyEditorZone
        Inherits EditorZone

        Protected Overrides Function CreateEditorPartChrome() As System.Web.UI.WebControls.WebParts.EditorPartChrome
            Return New MyEditorPartChrome(Me)
        End Function
    End Class
End Namespace

설명

Chrome을 영역에 포함 된 각 웹 파트 컨트롤 또는 서버 컨트롤 프레임 주변 사용자 인터페이스 (UI) 요소를 참조 합니다. 테두리, 제목 표시줄, 아이콘, 제목 텍스트 및 제목 표시줄에 나타나는 동사 메뉴 컨트롤의 크롬에 포함 되어 있습니다. 크롬 모양의 영역 수준에서 설정 되 고 영역에 있는 모든 컨트롤에 적용 됩니다.

웹 파트 컨트롤 집합 사용 합니다 EditorPartChrome 에 대 한 크롬을 렌더링 하는 클래스 EditorPart 컨트롤입니다. 이 클래스는 개발자가 모든 렌더링을 사용자 지정할 수 있는 방법을 제공 하는 또한 EditorPart 컨트롤을 EditorZoneBase 영역입니다. 예를 들어 재정의할 수 있습니다는 CreateEditorPartChromeStyle 에 정의 된 특정 스타일 특성을 사용자 지정 하는 메서드는 EditorZoneBase 영역입니다.

합니다 EditorPartChrome 클래스의 렌더링을 재정의 하려는 경우 유용할 수 있는 몇 가지 중요 한 메서드가 포함 되어 EditorPart 컨트롤입니다. 하나는 EditorPartChrome 생성자를 재정의 하는 경우를 사용 합니다 CreateEditorPartChrome 사용자 지정의 메서드 EditorZoneBase 사용자의 인스턴스를 만드는 클래스 EditorPartChrome 개체입니다. 또 다른 유용한 방법은 RenderPartContents (대신 chrome 요소 머리글, 바닥글 및 제목 표시줄 등) 영역의 컨트롤의 콘텐츠 영역 렌더링을 제어 하는 데 사용할 수 있는 메서드. 마지막으로, 모든 부분 렌더링을 완료 프로그래밍 방식으로 제어 하려는 경우는 EditorPart 컨트롤을 재정의할 수 있습니다는 RenderEditorPart 메서드.

상속자 참고

상속 하는 경우는 EditorPartChrome 클래스를 만들어야 합니다를 사용자 지정 EditorZone 영역에 사용자 지정 된 반환할 EditorPartChrome 클래스입니다. 이 클래스 개요의 예제 단원에는 사용자 지정을 만드는 방법을 보여 줍니다 EditorZone 사용자 지정 반환할 영역 EditorPartChrome 클래스

생성자

EditorPartChrome(EditorZoneBase)

EditorPartChrome 클래스의 새 인스턴스를 초기화합니다.

속성

Zone

관련 EditorZoneBase 영역에 대한 참조를 가져옵니다.

메서드

CreateEditorPartChromeStyle(EditorPart, PartChromeType)

EditorPart 개체로 렌더링된 각 EditorPartChrome 컨트롤에 대한 스타일 특성을 제공하는 스타일 개체를 만듭니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
PerformPreRender()

EditorPart 컨트롤을 렌더링하기 전에 수행해야 할 작업을 수행합니다.

RenderEditorPart(HtmlTextWriter, EditorPart)

해당 섹션을 모두 사용하여 EditorPart 컨트롤 전체를 렌더링합니다.

RenderPartContents(HtmlTextWriter, EditorPart)

머리글과 바닥글을 제외한 EditorPart 컨트롤의 주 콘텐츠 영역을 렌더링합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상