How to add a default value to a custom ASP.NET Profile property
- by mr.moses
I know you can add defaultValues using the web.config like this:
<profile>
<properties>
<add name="AreCool" type="System.Boolean" defaultValue="False" />
</properties>
</profile>
but I have the Profile inherited from a class:
<profile inherits="CustomProfile" defaultProvider="CustomProfileProvider" enabled="true">
<providers>
<clear />
<add name="CustomProfileProvider" type="CustomProfileProvider" />
</providers>
</profile>
Heres the class:
Public Class CustomProfile
Inherits ProfileBase
Public Property AreCool() As Boolean
Get
Return Me.GetPropertyValue("AreCool")
End Get
Set(ByVal value As Boolean)
Me.SetPropertyValue("AreCool", value)
End Set
End Property
End Class
I don't know how to set the default value of the property. Its causing errors because without a default value, it uses an empty string, which cannot be converted to a Boolean. I tried adding <DefaultSettingValue("False")> _ but that didn't seem to make a difference.
I'm also using a custom ProfileProvider (CustomProfileProvider).