WebPropertyEditor Class
The base class for Property Editors that use controls inherited from a System.Web.UI.WebControls.WebControl.
Namespace: DevExpress.ExpressApp.Web.Editors
Assembly: DevExpress.ExpressApp.Web.v24.1.dll
NuGet Package: DevExpress.ExpressApp.Web
Declaration
public abstract class WebPropertyEditor :
PropertyEditor,
ISupportViewEditMode,
IAppearanceFormat,
IAppearanceBase,
ISupportToolTip,
ISupportImmediatePostData
Related API Members
The following members return WebPropertyEditor objects:
Remarks
Inherit the WebPropertyEditor class to implement a Property Editor using third-party or custom ASP.NET Web Forms controls. If you use DevExpress controls inherited from ASPxEditBase, use the ASPxPropertyEditor class instead.
In ASP.NET Web Forms XAF applications, Detail Views can be displayed in two modes - view (read only) and edit (editable). To support these modes, the WebPropertyEditor class introduces the following properties:
Member | Description |
---|---|
ViewEditMode | Specifies the current display mode of the Property Editor’s control. |
Editor | Returns the Property Editor’s control used in edit mode. |
InplaceViewModeEditor | Returns the Property Editor’s control used in view mode. |
The WebPropertyEditor class implements the IAppearanceFormat interface to support conditional appearance rules.
Inherit WebPropertyEditor
Specify and Setup the Edit Mode Control
The CreateEditModeControlCore abstract method:
- Instantiates the control to be used in the edit mode.
- Performs the initial setup of the control.
Subscribes to control’s events that occur on a control value change. Each event handler calls the EditValueChangedHandler method. The EditValueChangedHandler method is the general-purpose handler for value-changed events. This method raises the ControlValueChanged event and calls the WriteValue() method.
The ReadEditModeValueCore abstract method passes the PropertyValue to the property of the Editor control specifying the displayed content (e.g., Text, Value, etc.).
The GetControlValueCore abstract method returns the value specified by the WebPropertyEditor.Editor control used in the edit mode.
Customize the View Mode Control (Optionally)
The System.Web.UI.WebControls.Label control is used in the view mode by default. Override these methods to customize the label’s string representation or to use another control.
Override The GetPropertyDisplayValue method to customize the string representation of the property value.
The CreateViewModeControlCore method instantiates and initializes the control used in the view mode.
The ReadViewModeValueCore method passes the PropertyValue value to the property of the InplaceViewModeEditor control specifying the displayed content (e.g., Text, Value, etc.).
Additional Customizations
The SetupControl method instantiates and initializes the control for which the customization code is provided. This method is called when the control is initialized (the Init event occurs).
The BreakLinksToControl(Boolean) method disposes manually allocated resources and unsubscribes from control events.
The SetProcessValueChangedScript method registers a script passed to this method parameter to support the IModelOptionsWeb.ConfirmUnsavedChanges mode. The script is executed on the client side after the property value is changed by user. If you use any DevExpress web control, pass the script to the [EditClientSideEvents.ValueChanged]ValueChanged client-side event of the control’s ClientSideEvents object.
protected override void SetProcessValueChangedScript(string script) { if (Editor != null) { ClientSideEventsHelper.AssignClientHandlerSafe((ASPxSpinEdit)Editor, "ValueChanged", script, Guid.NewGuid().ToString()); } }
If you use a custom third-party control, you should implement a code that provides the script execution when a user updates the editor value.
The SetImmediatePostDataScript method registers a script passed to this method parameter to support the ImmediatePostDataAttribute functionality (it is called only when ImmediatePostData is true). The script should be executed on the client side after the property value is changed by a user. If you use any DevExpress web control, pass the script to the ValueChanged client-side event of the control’s ClientSideEvents object.
protected override void SetImmediatePostDataScript(string script) { ClientSideEventsHelper.AssignClientHandlerSafe((ASPxSpinEdit)Editor, "ValueChanged", script, Guid.NewGuid().ToString()); }
If you use a custom third-party control, you should implement a code that provides the script execution at the moment a user updates the editor value.
The ApplyReadOnly method assigns the AllowEdit value to the Enabled property of the Editor control used in the edit mode. You can apply extra customizations in this method.
Important
- A custom Property Editor that derives from the WebPropertyEditor should not throw exceptions. Exceptions thrown by such a Property Editor interrupt request processing. As a result, the application crashes.
- The WebPropertyEditor‘s descendant should be public.
- The WebPropertyEditor sets the ID value for the Editor and InplaceViewModeEditor controls. If you use a custom complex control with the inner controls hierarchy, set the ID for each inner control. For details, refer to the How to create controls dynamically article.
To see an example of a Property Editor derived from the WebPropertyEditor class, refer to the How to: Implement a Property Editor Based on Custom Controls (ASP.NET Web Forms).