Hey,
I need a way to initialize my web control's properties when it's dropped on the designer area. As "initialize" I mean: If my control has a property Prop1. I need to assign a value to Prop1 and I need this value to be persisted on ASPx.
I tried the following:
- Implement InitializeNewComponent on my ControlDesigner: This method is never called. It seems a bug.
- Implement Initialize on my ControlDesigner: This method is called, but somehow Visual Studio does not allow me to change control's property at this stage.
- Create a handler to IComponentChangeService.ComponentAdded (that was supposed to be called every time any control is created). This handler is never called.
My question: How do I initialize my control properties?
PS: I know how to set my control's properties. I use the following code that works fine on a smart-tag:
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.Component)["Prop1"];
descriptor.SetValue("Value");
Edit
I forgot to mention I cannot use ToolBoxData because I need to make processing to determine the value of the property