Custom web controls and custom properties
A few weeks ago i began migrating a client side control to inside a .net custom web control, this is the first time, ive created one of these from scratch, but the concept is nothing new to me.
So i setup my class, inherited the required base control and added a custom text property, which looked something like below:
<Bindable(
True), Category("
Appearance"), Description("
The title of the control"), DefaultValue("
"), Localizable(
True), Browsable(
True)> _
Property Text()
AsString Get If ViewState("
Text")
IsNothingThen ReturnString.Empty
Else Return ViewState("
Text").ToString
EndIf EndGet Set(
ByVal Value
AsString) ViewState("
Text") = Value
EndSet EndPropertyThe issue began when i started changing this value in the design editor, i found that i got the following error 'Content1:'value' could not be set on property 'Text'.'

To get around this add the following code:
| Implements IControlDesignerAccessor
|
The msdn documentation on this particular interface is here but to be brief it basiccly tells visual studio that you need to store variable information in the ide's viewstate equivelant.
Any comments? feel free to email me at ian.jowett@dnisoftware.co.uk.
Article created on 23-04-2009