473,657 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object Persistence

I am trying to persist an instance specific object without using a session
object. Is this possible?

For example:
Class object: Car
Properties: Make, Model

Car.Make = Ford
Car.Model = F150

I would like to persist the object across postbacks without using a session
object. Or, if I do have to use a session object, what is the cleanest
mechinsim. Right now I save the object in the session after each property
change.
Sep 18 '06 #1
3 1669
Try using ViewState:

[Category("Data" )]
[DefaultValue("" )]
[Bindable(true)]
public Car SelectedCar
{
get
{
object c = ViewState["SelectedCa r"];
return (c == null) ? new Car(): (Car)c;
}
set
{
ViewState["SelectedCa r"] = value;
}
}
Sep 18 '06 #2
If you are talking a single page, ViewState is an option for persistence.
You can also create static variables, but you will have to key them to the
user. This means you either stick them in session or create your own
"session" mechanism. There are also other built in ASP.NET cache mechanism
(a search for "cache" and "asp.net" should yeield at least one article).

I would not be as fearful of session in ASP.NET as we were in traditional
ASP. It is far less dangerous, esp. if you think things through and only
store objects that have session scope.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** ****
Think outside of the box!
*************** *************** *************** ****
"Robert" <Ro****@discuss ions.microsoft. comwrote in message
news:32******** *************** ***********@mic rosoft.com...
>I am trying to persist an instance specific object without using a session
object. Is this possible?

For example:
Class object: Car
Properties: Make, Model

Car.Make = Ford
Car.Model = F150

I would like to persist the object across postbacks without using a
session
object. Or, if I do have to use a session object, what is the cleanest
mechinsim. Right now I save the object in the session after each property
change.

Sep 18 '06 #3
Here are my views regarding your requirement

1. If the object is to be persisted across users think of Application objects
2. If the object is to be persisted across the pages for a user think of
session objects. If you are using ASP.NET 2.0 think of exploring Profile
Objects
3. If you want to persist the object across post back for a single page,
think of ViewState. ViewState has the limiation on amount of storage. If you
object is big ViewState might impact performance
4. If your object is big and you've performance consideration try DataCaching.
Data Caching persists user object on the IIS Memory. Data caching is similar
to Application objects. Data Caching cannot store too much of information.

Just analyze the above and figure out what's the best option for you....


"Robert" wrote:
I am trying to persist an instance specific object without using a session
object. Is this possible?

For example:
Class object: Car
Properties: Make, Model

Car.Make = Ford
Car.Model = F150

I would like to persist the object across postbacks without using a session
object. Or, if I do have to use a session object, what is the cleanest
mechinsim. Right now I save the object in the session after each property
change.
Sep 21 '06 #4

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

Similar topics

6
4178
by: Paolo Losi | last post by:
Hi all, I'm pretty new to the python language so please excuse me if this is FAQ... I'm very glad to be part of the list! :-) I'm looking into a way to implement a generic workflow framework with python. The basic idea is to use python scripts as the way to specify workflow behavior. The framework should not only use scripts as a specification language but is going to leverage on python interpreter for the execution of the scripts. One...
2
1366
by: object-relational persistence mapping | last post by:
Someone can tell me where I find a good Object-Relational Mapping library.
4
1583
by: Marcel Balcarek | last post by:
Hello, I have a page (page1.aspx) that builds some complex .NET objects. I successfully pass these objects to another different window (page2.aspx). How can I persist these objects on a POST back of the same window (page2.aspx)? Thank you Marcel
3
296
by: Jo Inferis | last post by:
So, I'm using a 3rd party com object via interop (already I can hear screams of anguish). This object was originally written to be used as the backend for multiple screens of a VB application. Now in this situation the object remains in memory the whole time, so persistence of data between screens is not a problem, but on the web I'm assuming (from previous experience) that we'll need to use Load and Commit methods on this object - where...
5
1495
by: Chris Spencer | last post by:
Before I get too carried away with something that's probably unnecessary, please allow me to throw around some ideas. I've been looking for a method of transparent, scalable, and human-readable object persistence, and I've tried the standard lib's Shelve, Zope's ZODB, Divmod's Axiom, and others. However, while they're all useful, none satisfies all my criteria. So I started writing some toy code of my own: http://paste.plone.org/5227 ...
6
1428
by: Peter Richardson | last post by:
Hi, I'm wondering if someone can help me with some design questions I have. I'm trying to create a class in C# to represent my customers. I know how to create teh Customer class and all, but my problem comes with some conceptual issues I have: Let's say I have a business layer and a data layer. I use a seperate assembly to host the business objects that I pass from one to another. That is, I have for example:
1
7095
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that someone who bothers to read all of it have some pointers. Note, I have posted the stack trace and the code exhibiting the problem further down so if you want to start by reading that, search for +++ Also note that I am unable to reproduce...
0
1582
by: Bill McCormick | last post by:
I'm looking for the best (easiest, cheapest, fastest, most flexible) way to implement object persistence in .NET 3.5. The object data is native XML, so serialization is a good option as well as SQL Server. In memory objects will have a state modifier that indicates some sort of progress on the object. In a file-system persistence solution, the state modifier would place have the object move through some number of different folders....
0
2388
myusernotyours
by: myusernotyours | last post by:
Hi all, Am trying to create a Java Desktop App that uses Java Persistence in Netbeans. The database is MS Access but I tried with Mysql and got the same error. When I run the app( Create the entity manager), I keep getting the following... Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named ReceiptingPU: The following providers:...
0
8399
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
8312
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
8827
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
8732
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...
1
8504
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6169
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
4159
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...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
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

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.