EditorPartDesigner Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides design-time support for EditorPart controls.
public ref class EditorPartDesigner : System::Web::UI::Design::WebControls::WebParts::PartDesigner
public class EditorPartDesigner : System.Web.UI.Design.WebControls.WebParts.PartDesigner
type EditorPartDesigner = class
inherit PartDesigner
Public Class EditorPartDesigner
Inherits PartDesigner
- Inheritance
-
EditorPartDesigner
Examples
The following code example creates a simple custom EditorPart control that allows the user to change the ToolTip property of the target control. The associated EditorPartDesigner validates the control and replaces the user input text box at design time with a label explaining that it is hidden.
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web.UI.Design.WebControls.WebParts;
/// <summary>
/// SecretEditorPart is a custom EditorPart control that
/// allows the end user to change the ToolTip property of
/// a control by typing the value into a TextBox.
/// SecretEditorPartDesigner hides the TextBox at design
/// time via the view control and replaces it with the
/// words "The textbox is now hidden."
/// </summary>
namespace Samples.AspNet.CS.Controls
{
[Designer(typeof(SecretEditorPartDesigner))]
public class SecretEditorPart : EditorPart
{
public CheckBox UseCustom = new CheckBox();
public TextBox TTTextBox = new TextBox();
protected override void CreateChildControls()
{
base.CreateChildControls();
Controls.Add(UseCustom);
Literal lApply = new Literal();
lApply.Text = "Apply custom ToolTip<br />";
Controls.Add(lApply);
Controls.Add(TTTextBox);
}
public override bool ApplyChanges()
{
EnsureChildControls();
try
{
WebPartToEdit.ToolTip = TTTextBox.Text;
}
catch
{
return false;
}
return true;
}
public override void SyncChanges()
{
// Abstract method not implemented for this example
return;
}
}
public class SecretEditorPartDesigner : EditorPartDesigner
{
public override void Initialize(IComponent component)
{
// Validate the associated control
if (!(component is SecretEditorPart))
{
string msg = "The associated control must be of type 'SecretEditorPart'";
throw new ArgumentException(msg);
}
base.Initialize(component);
}
public override string GetDesignTimeHtml()
{
// Access the view control.
SecretEditorPart sep = (SecretEditorPart)ViewControl;
// Hide the textbox.
sep.TTTextBox.Visible = false;
// Now generate the base rendering.
string designTimeHtml = base.GetDesignTimeHtml();
// Insert some text.
string segment = "</div>";
designTimeHtml = designTimeHtml.Replace(segment,
"The textbox is now hidden." + segment);
// Return the modified rendering.
return designTimeHtml;
}
}
}
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.ComponentModel
Imports System.Security.Permissions
Imports System.Web.UI.Design.WebControls.WebParts
' SecretEditorPart is a custom EditorPart control that
' allows the end user to change the ToolTip property of
' a control by typing the value into a TextBox.
' SecretEditorPartDesigner hides the TextBox at design
' time via the view control and replaces it with the
' words "The textbox is now hidden."
Namespace Samples.AspNet.VB.Controls
<Designer(GetType(SecretEditorPartDesigner))> _
Public Class SecretEditorPart
Inherits EditorPart
Public UseCustom As New CheckBox()
Public TTTextBox As New TextBox()
Protected Overrides Sub CreateChildControls()
MyBase.CreateChildControls()
Controls.Add(UseCustom)
Dim lApply As New Literal()
lApply.Text = "Apply custom ToolTip<br />"
Controls.Add(lApply)
Controls.Add(TTTextBox)
End Sub
Public Overrides Function ApplyChanges() As Boolean
EnsureChildControls()
Try
WebPartToEdit.ToolTip = TTTextBox.Text
Catch
Return False
End Try
Return True
End Function
Public Overrides Sub SyncChanges()
' Abstract method not implemented for this example
Return
End Sub
End Class
Public Class SecretEditorPartDesigner
Inherits EditorPartDesigner
Public Overrides Sub Initialize(component As IComponent)
' Validate the associated control
If Not (TypeOf component Is SecretEditorPart) Then
Dim msg As String = "The associated control must be of type 'SecretEditorPart'"
Throw New ArgumentException(msg)
End If
MyBase.Initialize(component)
End Sub
Public Overrides Function GetDesignTimeHtml() As String
' Access the view control.
Dim sep As SecretEditorPart = DirectCast(ViewControl, SecretEditorPart)
' Hide the textbox.
sep.TTTextBox.Visible = False
' Now generate the base rendering.
Dim designTimeHtml As String = MyBase.GetDesignTimeHtml()
' Insert some text.
Dim segment As String = "</div>"
designTimeHtml = designTimeHtml.Replace(segment, "The textbox is now hidden." & segment)
' Return the modified rendering.
Return designTimeHtml
End Function
End Class
End Namespace
In order for the custom control to render, the page must have a WebPartManager control, an EditorZone with a ZoneTemplate for the control to reside in, and a WebPartZone containing a control for the custom EditorPart to act on, as shown in the following code example.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagPrefix="ccl" Namespace="Samples.AspNet.CS.Controls" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>EditorPartDesigner Sample</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:WebPartManager ID="WebPartManager1" runat="server">
</asp:WebPartManager><br />
<asp:EditorZone ID="EditorZone1" runat="server" Enabled="true" >
<ZoneTemplate>
<ccl:SecretEditorPart ID="SEPart1" runat="server" />
</ZoneTemplate>
</asp:EditorZone>
<asp:WebPartZone ID="WebPartZone1" runat="server">
<ZoneTemplate>
<asp:Button ID="Button1" runat="server" Height="24px" Text="Button" />
</ZoneTemplate>
</asp:WebPartZone><br />
</div>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagPrefix="ccl" Namespace="Samples.AspNet.VB.Controls" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>EditorPartDesigner Sample</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:WebPartManager ID="WebPartManager1" runat="server">
</asp:WebPartManager><br />
<asp:EditorZone ID="EditorZone1" runat="server" Enabled="true" >
<ZoneTemplate>
<ccl:SecretEditorPart ID="SEPart1" runat="server" />
</ZoneTemplate>
</asp:EditorZone>
<asp:WebPartZone ID="WebPartZone1" runat="server">
<ZoneTemplate>
<asp:Button ID="Button1" runat="server" Height="24px" Text="Button" />
</ZoneTemplate>
</asp:WebPartZone><br />
</div>
</form>
</body>
</html>
For the EditorPart to be usable at run time, edit mode must be enabled on the page. The following code example demonstrates how to do so with a code-behind file.
using System;
using System.Web.UI.WebControls.WebParts;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
{
// Make the 'Edit' verb available so the EditorZone can render
WebPartManager mgr = WebPartManager.GetCurrentWebPartManager(Page);
mgr.DisplayMode = mgr.SupportedDisplayModes["Edit"];
}
}
}
Imports System.Web.UI.WebControls.WebParts
Public Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs)
If True Then
' Make the 'Edit' verb available so the EditorZone can render
Dim mgr As WebPartManager = WebPartManager.GetCurrentWebPartManager(Page)
mgr.DisplayMode = mgr.SupportedDisplayModes("Edit")
End If
End Sub
End Class
Remarks
EditorPartDesigner is a public implementation of the PartDesigner base class for the purpose of rendering EditorPart controls at design time. It adds the capability of carrying zone information from the associated control into design view, but does not otherwise change the functionality of the parent control.
As with other control designers, you can change the design-time rendering of custom EditorPart controls by inheriting from EditorPartDesigner and overriding the GetDesignTimeHtml method. If you want to override the CreateViewControl method, be sure to include the base implementation so as to retain zone information.
Constructors
EditorPartDesigner() |
Initializes a new instance of the EditorPartDesigner class. |
Properties
ActionLists |
Gets the action list collection for the control designer. (Inherited from ControlDesigner) |
AllowResize |
Gets a value indicating whether the control can be resized in the design-time environment. (Inherited from ControlDesigner) |
AssociatedComponents |
Gets the collection of components associated with the component managed by the designer. (Inherited from ComponentDesigner) |
AutoFormats |
Gets the collection of predefined automatic formatting schemes to display in the Auto Format dialog box for the associated control at design time. (Inherited from ControlDesigner) |
Behavior |
Obsolete.
Gets or sets the DHTML behavior that is associated with the designer. (Inherited from HtmlControlDesigner) |
Component |
Gets the component this designer is designing. (Inherited from ComponentDesigner) |
DataBindings |
Gets the data bindings collection for the current control. (Inherited from HtmlControlDesigner) |
DataBindingsEnabled |
Gets a value indicating whether data binding is supported by the containing region for the associated control. (Inherited from ControlDesigner) |
DesignerState |
Gets an object that is used to persist data for the associated control at design time. (Inherited from ControlDesigner) |
DesignTimeElement |
Obsolete.
Gets the design-time object representing the control that is associated with the HtmlControlDesigner object on the design surface. (Inherited from HtmlControlDesigner) |
DesignTimeElementView |
Obsolete.
Gets the view-control object for the control designer. (Inherited from ControlDesigner) |
DesignTimeHtmlRequiresLoadComplete |
Obsolete.
Gets a value indicating whether the design host must finish loading before the GetDesignTimeHtml method can be called. (Inherited from ControlDesigner) |
Expressions |
Gets the expression bindings for the current control at design time. (Inherited from HtmlControlDesigner) |
HidePropertiesInTemplateMode |
Gets a value indicating whether the properties of the associated control are hidden when the control is in template mode. (Inherited from ControlDesigner) |
ID |
Gets or sets the ID string for the control. (Inherited from ControlDesigner) |
InheritanceAttribute |
Gets an attribute that indicates the type of inheritance of the associated component. (Inherited from ComponentDesigner) |
Inherited |
Gets a value indicating whether this component is inherited. (Inherited from ComponentDesigner) |
InTemplateMode |
Gets a value indicating whether the control is in either template viewing or editing mode in the design host. The InTemplateMode property is read-only. (Inherited from ControlDesigner) |
IsDirty |
Obsolete.
Gets or sets a value indicating whether the Web server control has been marked as changed. (Inherited from ControlDesigner) |
ParentComponent |
Gets the parent component for this designer. (Inherited from ComponentDesigner) |
ReadOnly |
Obsolete.
Gets or sets a value indicating whether the properties of the control are read-only at design time. (Inherited from ControlDesigner) |
RootDesigner |
Gets the control designer for the Web Forms page that contains the associated control. (Inherited from ControlDesigner) |
SetTextualDefaultProperty | (Inherited from ComponentDesigner) |
ShadowProperties |
Gets a collection of property values that override user settings. (Inherited from ComponentDesigner) |
ShouldCodeSerialize |
Obsolete.
Gets or sets a value indicating whether to create a field declaration for the control in the code-behind file for the current design document during serialization. (Inherited from HtmlControlDesigner) |
Tag |
Gets an object representing the HTML markup element for the associated control. (Inherited from ControlDesigner) |
TemplateGroups |
Gets a collection of template groups, each containing one or more template definitions. (Inherited from ControlDesigner) |
UsePreviewControl |
Gets a value indicating whether the designer should use a temporary copy rather than the actual control associated with the designer to generate the design-time markup. (Inherited from PartDesigner) |
Verbs |
Gets the design-time verbs supported by the component that is associated with the designer. (Inherited from ComponentDesigner) |
ViewControl |
Gets or sets a Web server control that can be used for previewing the design-time HTML markup. (Inherited from ControlDesigner) |
ViewControlCreated |
Gets or sets a value indicating whether a |
Visible |
Gets a value that indicates whether the control is visible at design time. (Inherited from ControlDesigner) |
Methods
CreateChildControls() |
Creates the child controls of this CompositeControl control. (Inherited from CompositeControlDesigner) |
CreateErrorDesignTimeHtml(String, Exception) |
Creates the HTML markup to display a specified exception error message at design time. (Inherited from ControlDesigner) |
CreateErrorDesignTimeHtml(String) |
Creates HTML markup to display a specified error message at design time. (Inherited from ControlDesigner) |
CreatePlaceHolderDesignTimeHtml() |
Provides a simple rectangular placeholder representation that displays the type and ID of the control. (Inherited from ControlDesigner) |
CreatePlaceHolderDesignTimeHtml(String) |
Provides a simple rectangular placeholder representation that displays the type and ID of the control, and also additional specified instructions or information. (Inherited from ControlDesigner) |
CreateViewControl() |
Creates a copy of the associated EditorPart control to render at design time. |
Dispose() |
Releases all resources used by the ComponentDesigner. (Inherited from ComponentDesigner) |
Dispose(Boolean) |
Releases the unmanaged resources that are used by the HtmlControlDesigner object and optionally releases the managed resources. (Inherited from HtmlControlDesigner) |
DoDefaultAction() |
Creates a method signature in the source code file for the default event on the component and navigates the user's cursor to that location. (Inherited from ComponentDesigner) |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetBounds() |
Retrieves the coordinates of the rectangle representing the boundaries for the control as displayed on the design surface. (Inherited from ControlDesigner) |
GetDesignTimeHtml() |
Verifies that the control resides in a zone of type EditorZoneBase, and then gets the markup that is used to represent the control at design time. |
GetDesignTimeHtml(DesignerRegionCollection) |
Retrieves the HTML markup to display the control and populates the collection with the current control designer regions. (Inherited from ControlDesigner) |
GetEditableDesignerRegionContent(EditableDesignerRegion) |
Returns the content for an editable region of the design-time view of the associated control. (Inherited from ControlDesigner) |
GetEmptyDesignTimeHtml() |
Retrieves the HTML markup to represent a Web server control at design time that will have no visual representation at run time. (Inherited from ControlDesigner) |
GetErrorDesignTimeHtml(Exception) |
Retrieves the HTML markup that provides information about the specified exception. (Inherited from ControlDesigner) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetPersistenceContent() |
Retrieves the persistable inner HTML markup of the control at design time. (Inherited from ControlDesigner) |
GetPersistInnerHtml() |
Obsolete.
Retrieves the persistable inner HTML markup of the control. (Inherited from ControlDesigner) |
GetService(Type) |
Attempts to retrieve the specified type of service from the design mode site of the designer's component. (Inherited from ComponentDesigner) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
GetViewRendering() |
Retrieves an object that contains the design-time markup for the content and regions of the associated control. (Inherited from ControlDesigner) |
Initialize(IComponent) |
Binds the designer to the associated EditorPart control. |
InitializeExistingComponent(IDictionary) |
Reinitializes an existing component. (Inherited from ComponentDesigner) |
InitializeNewComponent(IDictionary) |
Initializes a newly created component. (Inherited from ComponentDesigner) |
InitializeNonDefault() |
Obsolete.
Obsolete.
Initializes the settings for an imported component that is already initialized to settings other than the defaults. (Inherited from ComponentDesigner) |
Invalidate() |
Invalidates the whole area of the control that is displayed on the design surface and signals the control designer to redraw the control. (Inherited from ControlDesigner) |
Invalidate(Rectangle) |
Invalidates the specified area of the control that is displayed on the design surface and signals the control designer to redraw the control. (Inherited from ControlDesigner) |
InvokeGetInheritanceAttribute(ComponentDesigner) |
Gets the InheritanceAttribute of the specified ComponentDesigner. (Inherited from ComponentDesigner) |
IsPropertyBound(String) |
Obsolete.
Retrieves a value indicating whether the specified property on the associated control is data-bound. (Inherited from ControlDesigner) |
Localize(IDesignTimeResourceWriter) |
Uses the provided resource writer to persist the localizable properties of the associated control to a resource in the design host. (Inherited from ControlDesigner) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
OnAutoFormatApplied(DesignerAutoFormat) |
Called when a predefined, automatic formatting scheme has been applied to the associated control. (Inherited from ControlDesigner) |
OnBehaviorAttached() |
Called when the control designer is attached to a Behavior object. (Inherited from ControlDesigner) |
OnBehaviorDetaching() |
Obsolete.
Called when a behavior disassociates from the element. (Inherited from HtmlControlDesigner) |
OnBindingsCollectionChanged(String) |
Obsolete.
Called when the data-binding collection changes. (Inherited from ControlDesigner) |
OnClick(DesignerRegionMouseEventArgs) |
Called by the design host when the user clicks the associated control at design time. (Inherited from ControlDesigner) |
OnComponentChanged(Object, ComponentChangedEventArgs) |
Called when the associated control changes. (Inherited from ControlDesigner) |
OnComponentChanging(Object, ComponentChangingEventArgs) |
Represents the method that will handle the ComponentChanging event for the associated control. (Inherited from ControlDesigner) |
OnControlResize() |
Obsolete.
Called when the associated Web server control has been resized in the design host at design time. (Inherited from ControlDesigner) |
OnPaint(PaintEventArgs) |
Called when the control designer draws the associated control on the design surface, if the CustomPaint value is |
OnSetComponentDefaults() |
Obsolete.
Obsolete.
Sets the default properties for the component. (Inherited from ComponentDesigner) |
OnSetParent() |
Provides a way to perform additional processing when the associated control is attached to a parent control. (Inherited from HtmlControlDesigner) |
PostFilterAttributes(IDictionary) |
Allows a designer to change or remove items from the set of attributes that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner) |
PostFilterEvents(IDictionary) |
Allows a designer to change or remove items from the set of events that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner) |
PostFilterProperties(IDictionary) |
Allows a designer to change or remove items from the set of properties that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner) |
PreFilterAttributes(IDictionary) |
Allows a designer to add to the set of attributes that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner) |
PreFilterEvents(IDictionary) |
Sets the list of events that are exposed at design-time for the TypeDescriptor object for the component. (Inherited from HtmlControlDesigner) |
PreFilterProperties(IDictionary) |
Adds properties to or removes properties from the Properties grid in a design host at design time or provides new design-time properties that might correspond to properties on the associated control. (Inherited from ControlDesigner) |
RaiseComponentChanged(MemberDescriptor, Object, Object) |
Notifies the IComponentChangeService that this component has been changed. (Inherited from ComponentDesigner) |
RaiseComponentChanging(MemberDescriptor) |
Notifies the IComponentChangeService that this component is about to be changed. (Inherited from ComponentDesigner) |
RaiseResizeEvent() |
Obsolete.
Raises the OnControlResize() event. (Inherited from ControlDesigner) |
RegisterClone(Object, Object) |
Registers internal data in a cloned control. (Inherited from ControlDesigner) |
SetEditableDesignerRegionContent(EditableDesignerRegion, String) |
Specifies the content for an editable region of the control at design time. (Inherited from ControlDesigner) |
SetRegionContent(EditableDesignerRegion, String) |
Specifies the content for an editable region in the design-time view of the control. (Inherited from ControlDesigner) |
SetViewFlags(ViewFlags, Boolean) |
Assigns the specified bitwise ViewFlags enumeration to the specified flag value. (Inherited from ControlDesigner) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
UpdateDesignTimeHtml() |
Refreshes the design-time HTML markup for the associated Web server control by calling the GetDesignTimeHtml method. (Inherited from ControlDesigner) |