다음을 통해 공유


EditorPart.ApplyChanges 메서드

정의

컨트롤의 값을 EditorPart 연결된 WebPart 컨트롤의 해당 속성에 저장합니다.

public:
 abstract bool ApplyChanges();
public abstract bool ApplyChanges();
abstract member ApplyChanges : unit -> bool
Public MustOverride Function ApplyChanges () As Boolean

반품

컨트롤에서 컨트롤로 값을 저장하는 작업이 성공하면 />이고, 그렇지 않으면(오류가 발생하는 경우) .

예제

다음 코드 예제에서는 사용자 지정 EditorPart 컨트롤에서 메서드를 ApplyChanges 구현 하는 방법을 보여 줍니다. 예제를 실행하는 데 필요한 전체 코드는 클래스 개요의 예제 섹션을 EditorPart 참조하세요.

코드 예제의 첫 번째 부분은 명명TextDisplayEditorPart된 사용자 지정 EditorPart 클래스에서 메서드의 ApplyChanges 구현을 보여 줍니다. 이 메서드는 속성을 사용 하 여 연결 된 TextDisplayWebPart 컨트롤에 대 한 참조를 WebPartToEdit 가져옵니다. 그런 다음 속성 값을 업데이트합니다 TextDisplayWebPart.FontStyle .

public override bool ApplyChanges()
{
  TextDisplayWebPart part = 
    (TextDisplayWebPart)WebPartToEdit;
  // Update the custom WebPart control with the font style.
  part.FontStyle = PartContentFontStyle.SelectedValue;

  return true;
}
Public Overrides Function ApplyChanges() As Boolean
  Dim part As TextDisplayWebPart = CType(WebPartToEdit, _
                                         TextDisplayWebPart)
  ' Update the custom WebPart control with the font style.
  part.FontStyle = PartContentFontStyle.SelectedValue

  Return True

End Function

코드 예제의 두 번째 부분에서는 연결된 WebPart 컨트롤TextDisplayWebPart이 메서드 구현에서 연결된 컨트롤의 컬렉션을 만드는 방법을 보여 줍니다(이 경우 컬렉션에 명명 TextDisplayEditorPartEditorPart 컨트롤이 하나 EditorPart 만 있습니다)CreateEditorParts. 이 메서드는 컨트롤이 편집 모드로 TextDisplayWebPart 전환될 때 실행됩니다.

public override EditorPartCollection CreateEditorParts()
{
  ArrayList editorArray = new ArrayList();
  TextDisplayEditorPart edPart = new TextDisplayEditorPart();
  edPart.ID = this.ID + "_editorPart1";
  editorArray.Add(edPart);
  EditorPartCollection editorParts = 
    new EditorPartCollection(editorArray);
  return editorParts;
}

public override object WebBrowsableObject
{
  get { return this; }
}
Public Overrides Function CreateEditorParts() _
                            As EditorPartCollection
  Dim editorArray As New ArrayList()
  Dim edPart as New TextDisplayEditorPart()
  edPart.ID = Me.ID & "_editorPart1"
  editorArray.Add(edPart)
  Dim editorParts As New EditorPartCollection(editorArray)
  Return editorParts

End Function

Public Overrides ReadOnly Property WebBrowsableObject() _
                                    As Object
  Get
    Return Me
  End Get
End Property

설명

ApplyChanges 메서드는 컨트롤에서 중요한 메서드입니다 EditorPart . 클래스에서 EditorPart 추상 메서드로 정의되며 상속된 컨트롤에 의해 구현되어야 합니다. 이 메서드의 목적은 사용자가 컨트롤에 입력한 값을 속성에서 EditorPart 참조되는 컨트롤의 WebPart 해당 속성에 WebPartToEdit 저장하는 것입니다.

ApplyChanges 메서드는 사용자가 편집 UI(사용자 인터페이스)에서 확인 또는 적용 동사를 나타내는 단추를 클릭할 때 호출됩니다.

구현자 참고

클래스에서 파생되는 클래스는 메서드를 EditorPartApplyChanges() 구현해야 합니다. 구현된 메서드는 속성을 사용하여 연결된 컨트롤에 WebPartToEdit 대한 참조를 가져오고 해당 컨트롤의 속성을 컨트롤의 현재 값 EditorPart 으로 업데이트합니다.

적용 대상

추가 정보