473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to NOT serialize a Property of a Class

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.W ebcontrols.Webc ontrol
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.W ebControls.WebC ontrol
Get
Return _myControl
End Get
Set(ByVal Value As System.Web.UI.W ebControls.WebC ontrol)
_myControl = Value
End Set
End Property
Nov 18 '05 #1
3 2739
Hi,

The first thing that comes to mind is using two separate methods for
getting/seting (eg: Get_myControl() and Set_myControl(V alue As WebControl))
the field (_myControl) instead of the property (myControl()). Then just mark
the field _myControl with the NonSerializedAt tribute.

Hope this helps
Martin
"Earl Teigrob" <Ea*********@di scussions.micro soft.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
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.W ebcontrols.Webc ontrol
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.W ebControls.WebC ontrol
Get
Return _myControl
End Get
Set(ByVal Value As System.Web.UI.W ebControls.WebC ontrol)
_myControl = Value
End Set
End Property

Nov 18 '05 #2
<System.Xml.Ser ialization.XmlI gnore()> _
Property myControl() As System.Web.UI.W ebControls.WebC ontrol
Get
Return _myControl
End Get
Set(ByVal Value As System.Web.UI.W ebControls.WebC ontrol)
_myControl = Value
End Set
End Property
Hope this helps

Blu.
Nov 18 '05 #3
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.W ebControls.WebC ontrol

....

<System.Xml.Ser ialization.XmlI gnore()> _
Property RenderControl() As System.Web.UI.W ebControls.WebC ontrol
Get
If Not _RenderControl Is Nothing Then
Return _RenderControl
Else
_RenderControl =
System.Activato r.CreateInstanc e(ControlType)
_RenderControl. ID = ControlId
Return _RenderControl
End If
End Get
Set(ByVal Value As System.Web.UI.W ebControls.WebC ontrol)
_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.W ebcontrols.Webc ontrol
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.W ebControls.WebC ontrol
Get
Return _myControl
End Get
Set(ByVal Value As System.Web.UI.W ebControls.WebC ontrol)
_myControl = Value
End Set
End Property

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2071
by: John Manion via .NET 247 | last post by:
Long Post, thanks for your patience... I have and XML file that looks something like this: <?xml version="1.0" encoding="utf-8" ?> <Settings> <Location> <X>30</X> <Y>40</Y> </Location> <Size>
1
2252
by: Rick Luckwell | last post by:
I have 3 collections(reports, services, charts) of objects(report, service, chart) that are nested with each other. When I serialize the object the output only contains reports and services but not the charts. Am I missing something? can you serialize to this depth without extra code? or do I need to call the serialize method of the child objects? clsReports.SerializeObject("c:\report.xml", m_AllReports) '"m_AllReports" contains the...
1
3669
by: davebaranas | last post by:
I am able to serialize this but I get a null exception when I try to deserialize it back Even if I don't make any child classes it throws "Object reference not set to an instance of an object." I must be missing something here Private Sub cmdLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLoad.Click
4
7142
by: =?Utf-8?B?Qnlyb24=?= | last post by:
When I try to serialize an instance of the LocationCell below (note Building field) I get an error in the reflection attempt. If I remove the _Building field it serializes fine. I tried renaming Building._Name to Building._BName in case the duplicate name was the issue, but that didn't help. Is there a native way to serialize nested objects, or will I have to write my own? public class LocationCell
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.