Enum and the designer

M

milop

Hello.

I have an ASP.Net 2.0 web application.

I have an Enum in a BLL layer. The BLL is a seperate project in the Web App
solution:
NameSpace MyNamespace
<Flags(), Serializable()> _
Public Enum ProductTypes As ULong
Alarm = 1
Oil = 2
AirConditioning = 4
Gas = 8
IWT = 16
Budget = 32
Other = 512
End Enum
End Namespace

I'm creating a custom control like so:

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports MyNamespace.BLL

<DefaultProperty("LedgerType"), ToolboxData("<{0}:wccLedgerValidator
runat=server></{0}:wccLedgerValidator>")> _
Public Class wccLedgerValidator
Inherits WebControl

Private _LedgerType As LedgerTypes

<Bindable(True), Category("Behavior"), DefaultValue("Alarm"),
Localizable(True)> _
Public Property LedgerType() As LedgerTypes
Get
Return _LedgerType
End Get
Set(ByVal Value As LedgerTypes)
_LedgerType = Value
End Set
End Property

Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter)
If Me.DesignMode = True Then
Select Case _LedgerType
Case LedgerTypes.AirConditioning
writer.Write("AirConditioning")

Case LedgerTypes.Alarm
writer.Write("Alarm")

Case LedgerTypes.Budget
writer.Write("Budget")

Case LedgerTypes.Gas
writer.Write("Gas")

Case LedgerTypes.IWT
writer.Write("IWT")

Case LedgerTypes.Oil
writer.Write("Oil")

Case LedgerTypes.Other
writer.Write("Other")

Case Else
writer.Write("Unknown")

End Select

End If

End Sub

End Class

When I drop this control onto an .aspx page and set the property to "Alarm"
let's say, everything is fine. However, if I switch the designer mode to
Source mode and then try to switch back to Design mode I get the following
error:

'Alarm' could not be set on property 'LedgerType'

and the page cannot be shown in design mode.

It's as if VS cannot map the LedgerType property value to the Enum.

Any ideas?

Thanks in advance,

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top