19. October 2006 06:37
I have dealt with this issue twice already, once being yesterday, and both times I found it very hard to find the solution. Therefore, i'm posting about it, not only for people to find the solution to their problem, but also for a reminder for me.
Anyway, developing Web Custom Controls is cool. It saves you time by using code reusability and the best part is Visual Studio makes it very easy to create one. Whenever you have properties on a control, by default they are shown on the property window of the control and whenever you set a property for the first time it adds an attribute to the tag element of that control. For example, if you set the visible property of a textbox to false at design time and then switch to the source, the textbox tag now looks like this:
<asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>
(note the Visible attribute.) This is the way Visual Studio implements state for design time properties. The good news is you don't have to do anything special on your control for that to work. The not so good news is that this works for primitive types like Strings, Integer, Booleans or even Enums, but not so well with collections. In order for this to work, you have to set an attributes at the property level of the control: