Edited by SomeNewKid. Please post code between <code> and </code> tags.
I have a control that has a property of type collection. When I add the control to the page
and add couple of items to collection property it runs fine with no problem. When I exit Visual Studio.NET and get back again the control's tag has error message Error Creating Control with tooltip saying " '' could not be set on property 'UserInfos' " how ever page still runs fine, but the problem is when tag has an error I can no longer edit its properties in property panel.
If you have any ideas please advice.
Bellow is the code for my control:
---------CONTROL CLASS---------------
Imports System.Web.UI
Imports System.ComponentModel
<ParseChildren(True, "UserInfos"), PersistChildren(False), _
PersistenceMode(PersistenceMode.InnerProperty), _
ToolboxData("<{0}:EmployeeControl runat=server></{0}:EmployeeControl>")> _
Public Class EmployeeControl
Inherits System.Web.UI.WebControls.WebControl
Private _userCollection As New UserCollection
<Category("Custom"), NotifyParentProperty(True), _
PersistenceMode(PersistenceMode.InnerDefaultProperty), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public Property UserInfos() As UserCollection
Get
Return _userCollection
End Get
Set(ByVal Value As UserCollection)
_userCollection = Value
End Set
End Property
End Class
-----------COLLECTION CLASS-----------------
Imports System.ComponentModel
Imports System.Web.UI
'<TypeConverter(GetType(ExpandableObjectConverter))> _
Public Class UserCollection
Inherits CollectionBase
Default Public Property Item(ByVal index As Integer) As UserInfo
Get
Return CType(List(index), UserInfo)
End Get
Set(ByVal Value As UserInfo)
List(index) = Value
End Set
End Property
Public Function Add(ByVal value As UserInfo) As Integer
Return List.Add(value)
End Function 'Add
Public Function IndexOf(ByVal value As UserInfo) As Integer
Return List.IndexOf(value)
End Function 'IndexOf
Public Sub Insert(ByVal index As Integer, ByVal value As UserInfo)
List.Insert(index, value)
End Sub 'Insert
Public Sub Remove(ByVal value As UserInfo)
List.Remove(value)
End Sub 'Remove
End Class
-------------TYPE CLASS----------------
Imports System.ComponentModel
Public Class UserInfo
Public strFirstName As String = ""
Public strLastName As String = ""
Public iUserId As Integer = 0
Property [FirstName]() As String
Get
Return strFirstName
End Get
Set(ByVal Value As String)
strFirstName = Value
End Set
End Property
Property [LastName]() As String
Get
Return strLastName
End Get
Set(ByVal Value As String)
strLastName = Value
End Set
End Property
Property [UserID]() As Integer 'UserIDCollection
Get
Return iUserId
End Get
Set(ByVal Value As Integer) 'UserIDCollection)
iUserId = Value
End Set
End Property
End Class