Saves the values in an EditorPart control to the corresponding properties in the associated WebPart control.
Namespace:
System.Web.UI.WebControls.WebParts
Assembly:
System.Web (in System.Web.dll)
Visual Basic (Declaration)
Public MustOverride Function ApplyChanges As Boolean
Dim instance As EditorPart
Dim returnValue As Boolean
returnValue = instance.ApplyChanges()
public abstract bool ApplyChanges()
public:
virtual bool ApplyChanges() abstract
public abstract function ApplyChanges() : boolean
Return Value
Type:
System..::.Boolean
true if the action of saving values from the EditorPart control to the WebPart control is successful; otherwise (if an error occurs), false.
The ApplyChanges method is a critical method on an EditorPart control. It is defined as an abstract method in the EditorPart class, and must be implemented by inherited controls. The method's purpose is to save the values a user has entered into an EditorPart control to the corresponding properties in the WebPart control that is referenced in the WebPartToEdit property.
The ApplyChanges method is called when the user clicks a button representing an OK or an apply verb in the editing user interface (UI).
Notes to Inheritors: A class that derives from the EditorPart class must implement the ApplyChanges method. The implemented method gets a reference to the associated control using the WebPartToEdit property, and then updates the properties of that control with the current values in the EditorPart control.
The following code example demonstrates how to implement the ApplyChanges method in a custom EditorPart control. For the full code required to run the example, see the Example section of the EditorPart class overview.
The first part of the code example demonstrates the implementation of the ApplyChanges method in the custom EditorPart class named TextDisplayEditorPart. This method gets a reference to the associated TextDisplayWebPart control using the WebPartToEdit property. It then updates the value of the TextDisplayWebPart.FontStyle property.
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
public override bool ApplyChanges()
{
TextDisplayWebPart part =
(TextDisplayWebPart)WebPartToEdit;
// Update the custom WebPart control with the font style.
part.FontStyle = PartContentFontStyle.SelectedValue;
return true;
}
The second part of the code example shows how the associated WebPart control, TextDisplayWebPart, creates a collection of associated EditorPart controls (in this case, there is only one EditorPart control named TextDisplayEditorPart in the collection) in its implementation of the CreateEditorParts method. This method is executed when the TextDisplayWebPart control enters edit mode.
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
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; }
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0
Reference
Other Resources