Thank you Both ForYour answers. I used the combination of your answers to
solve my issue and it works great! Here is what my class ends up looking like
<Serializable()> _
Class TabMenuItem
....
<NonSerialized()> Private _RenderControl As
System.Web.UI.WebControls.WebControl
....
<System.Xml.Serialization.XmlIgnore()> _
Property RenderControl() As System.Web.UI.WebControls.WebControl
Get
If Not _RenderControl Is Nothing Then
Return _RenderControl
Else
_RenderControl =
System.Activator.CreateInstance(ControlType)
_RenderControl.ID = ControlId
Return _RenderControl
End If
End Get
Set(ByVal Value As System.Web.UI.WebControls.WebControl)
_RenderControl = Value
ControlType = Value.GetType
ControlId = Value.ID
End Set
End Property
....
End Class
"Earl Teigrob" wrote:
I have a class that has some fields and properties that I want to serialize.
However, one of the fields is of type System.Web.UI.Webcontrols.Webcontrol
and it will not serialize so I want to mark it as "NonSerialized". However,
this property is not allowed on a property of this type. How can I designate
this property so that I can serialize the rest of the call without
serializing this property???
Thanks!
Property myControl() As System.Web.UI.WebControls.WebControl
Get
Return _myControl
End Get
Set(ByVal Value As System.Web.UI.WebControls.WebControl)
_myControl = Value
End Set
End Property