We have just added the first property member to our custom Property Editor class, thus enabling this class to expose a public way of getting and setting its values. Now we are going to see how this property can be changed from component code using PropertyEditorInit attribute.
The custom Property Editor can be initialised with some of the standard Text Area attributes or style properties. For this example, rows and word wrap attributes value will be used. By simple addition of PropertyEditorInit attribute in the component’s property code, the value of property member in a Property Editor class can be set to some initial value at runtime.
[PropertyEditorInit("Rows", 2)] [PropertyEditorInit("WordWrap", true)]
These members can be used at a later stage in such way that, by adding data attributes, their values specify custom information to HTML elements in our own rendering code for the custom Property Editor. Recall that we had already used and assigned class, id and name attributes to our textBox
HtmlGenericControl in the RenderInput(...) method of the custom Property Editor.
Rows and WordWrap properties are set by getting the value provided by [PropertyEditorInit(...))].