T
Todd Lucas
I'm having some weird things happen in design view while editing a custom collection - I've been at this for about 4 weeks now, and have tried all the different combinations of persistence settings (DesignerSerializationVisibility, PersistenceMode, etc) there is, and all to no avail! I'm hoping someone here can help ..
Environment: VS.NET 2003 v7.1.3088, Win2000 v5.00.2195 SP3, IE6 v6.0.2800.1106C
The problem is one of collection item persistence. The problem can be repeated by using the following steps
1) create new webform, and drop C3Menu control on it from Toolbox
2) click control to select it
3) click ellipse button on the MenuItems property to edit collection (via standard CollectionEditor)
4) add a new item, and click Ok button to save changes / close collection editor
5) switch to HTML view - changes are persisted ok
6) switch back to design view, and run the test project
7) control appears fine on webform, with all items listed
8) close webform to return to design view
9) click control to select it
10) click ellipse button on the MenuItems property to edit collection (via standard CollectionEditor)
11) add a new item, and click Ok button to save changes / close collection editor
12) switch to HTML view - changes are NOT persisted
It gets even weirder, because if I repeat steps 9-12 a second time (right after doing all 12) to add another new item, the previous item AND the second new item are persisted
If I remove the "SET" accessor on the MenuItems property in the C3Menu class, a new problem is presented: "Design View: Error creating control - '' could not be set on property MenuItems". This problem occurs if I close the webform after adding items to the collection, and try to reopen it. The application still runs ok, and the control is presented properly on the webform at run time, but the designer complains that the control cannot be created (above message) - I then cannot access any properties for the control in design view, but can add new items in the HTML view and they appear fine on the webform at run time
Any ideas? I would be happy to send the full source code to anyone that wants to help. Any help would be appreciated
Thanks - Tod
The Code (snippets)
[code
C3Menu Class
<DefaultEvent("ItemClick"),
Description("Server Control - Menu Definition."),
ParseChildren(True, "MenuItems"), PersistChildren(False),
ToolboxData("<{0}:C3Menu runat=server></{0}:C3Menu>")>
Public Class C3Menu : Inherits System.Web.UI.WebControls.WebContro
...
Dim _menuitems As New C3MenuItemCollectio
...
<Category("Menu Properties"), NotifyParentProperty(True),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerDefaultProperty),
Description("Collection of Menu Items this object will display.")>
ReadOnly Property [MenuItems]() As C3MenuItemCollectio
Ge
Return _menuitem
End Ge
' ** Note - SET causes control creation errors when the page is loaded
Set(ByVal Value As C3MenuItemCollection
If Not IsNothing(Value) Then _menuitems = Valu
End Se
End Propert
...
C3MenuItemCollection Class
Public Class C3MenuItemCollection : Inherits System.Collections.CollectionBas
Public Sub New(
MyBase.New(
End Su
Default Public Property Item(ByVal index As Integer) As C3MenuIte
Ge
Return CType(Me.List(index), C3MenuItem
End Ge
Set(ByVal Value As C3MenuItem
Me.List(index) = Valu
End Se
End Propert
Public Function Add(ByVal value As C3MenuItem) As Intege
Return Me.List.Add(value
End Functio
Public Function Contains(ByVal value As C3MenuItem) As Boolea
Return Me.List.Contains(value
End Functio
Public Function IndexOf(ByVal value As C3MenuItem) As Intege
Return Me.List.IndexOf(value
End Functio
Public Sub Remove(ByVal value As C3MenuItem
Me.List.Remove(value)
End Sub
Public Sub Insert(ByVal index As Integer, ByVal value As C3MenuItem)
Me.List.Insert(index, value)
End Sub
End Class
C3MenuItem Class:
(All properties in this class are one of the following types: String, Boolean, Color)
Public Class C3MenuItem
Public pOwningMenu As C3Menu
' MenuItem property storage:
Dim _align As String = ""
Dim _closeonclick As Boolean = True
Dim _color3dlow As Color = ColorTranslator.FromHtml("")
....
[/code]
Environment: VS.NET 2003 v7.1.3088, Win2000 v5.00.2195 SP3, IE6 v6.0.2800.1106C
The problem is one of collection item persistence. The problem can be repeated by using the following steps
1) create new webform, and drop C3Menu control on it from Toolbox
2) click control to select it
3) click ellipse button on the MenuItems property to edit collection (via standard CollectionEditor)
4) add a new item, and click Ok button to save changes / close collection editor
5) switch to HTML view - changes are persisted ok
6) switch back to design view, and run the test project
7) control appears fine on webform, with all items listed
8) close webform to return to design view
9) click control to select it
10) click ellipse button on the MenuItems property to edit collection (via standard CollectionEditor)
11) add a new item, and click Ok button to save changes / close collection editor
12) switch to HTML view - changes are NOT persisted
It gets even weirder, because if I repeat steps 9-12 a second time (right after doing all 12) to add another new item, the previous item AND the second new item are persisted
If I remove the "SET" accessor on the MenuItems property in the C3Menu class, a new problem is presented: "Design View: Error creating control - '' could not be set on property MenuItems". This problem occurs if I close the webform after adding items to the collection, and try to reopen it. The application still runs ok, and the control is presented properly on the webform at run time, but the designer complains that the control cannot be created (above message) - I then cannot access any properties for the control in design view, but can add new items in the HTML view and they appear fine on the webform at run time
Any ideas? I would be happy to send the full source code to anyone that wants to help. Any help would be appreciated
Thanks - Tod
The Code (snippets)
[code
C3Menu Class
<DefaultEvent("ItemClick"),
Description("Server Control - Menu Definition."),
ParseChildren(True, "MenuItems"), PersistChildren(False),
ToolboxData("<{0}:C3Menu runat=server></{0}:C3Menu>")>
Public Class C3Menu : Inherits System.Web.UI.WebControls.WebContro
...
Dim _menuitems As New C3MenuItemCollectio
...
<Category("Menu Properties"), NotifyParentProperty(True),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerDefaultProperty),
Description("Collection of Menu Items this object will display.")>
ReadOnly Property [MenuItems]() As C3MenuItemCollectio
Ge
Return _menuitem
End Ge
' ** Note - SET causes control creation errors when the page is loaded
Set(ByVal Value As C3MenuItemCollection
If Not IsNothing(Value) Then _menuitems = Valu
End Se
End Propert
...
C3MenuItemCollection Class
Public Class C3MenuItemCollection : Inherits System.Collections.CollectionBas
Public Sub New(
MyBase.New(
End Su
Default Public Property Item(ByVal index As Integer) As C3MenuIte
Ge
Return CType(Me.List(index), C3MenuItem
End Ge
Set(ByVal Value As C3MenuItem
Me.List(index) = Valu
End Se
End Propert
Public Function Add(ByVal value As C3MenuItem) As Intege
Return Me.List.Add(value
End Functio
Public Function Contains(ByVal value As C3MenuItem) As Boolea
Return Me.List.Contains(value
End Functio
Public Function IndexOf(ByVal value As C3MenuItem) As Intege
Return Me.List.IndexOf(value
End Functio
Public Sub Remove(ByVal value As C3MenuItem
Me.List.Remove(value)
End Sub
Public Sub Insert(ByVal index As Integer, ByVal value As C3MenuItem)
Me.List.Insert(index, value)
End Sub
End Class
C3MenuItem Class:
(All properties in this class are one of the following types: String, Boolean, Color)
Public Class C3MenuItem
Public pOwningMenu As C3Menu
' MenuItem property storage:
Dim _align As String = ""
Dim _closeonclick As Boolean = True
Dim _color3dlow As Color = ColorTranslator.FromHtml("")
....
[/code]