Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey

 

I want to store the address of an object in the session and then recreate the reference later on by the address. Is this possible?

 

The reason im not storing the object in the session is because the object is large and i dont want to serialize it (the session is InProc). The object is also only going to be used during the current postback so i dont have to worry about the address pointing to the wrong object.

Posted
What is the object in question and what data does it hold that makes it so large? If it is only used in the current postback why do you need to persist it between postbacks?

 

The object in question is a ControlCollection.

 

I dont need to persist it between postbacks, just between different controls and modules in the same post back.

  • *Experts*
Posted
If you need to reference the ControlCollection in methods, I'd reccomend passing an instance of the ControlCollection directly via one of the method's parameters. Or is this not feasible for some reason?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted
If you need to reference the ControlCollection in methods' date=' I'd reccomend passing an instance of the ControlCollection directly via one of the method's parameters. Or is this not feasible for some reason?[/quote']

 

Its really not. I am creating a global interface to a set of dynamically created controls on the page that any class can access.

 

What about if I made a hash map in the global.asx file which would be indexed by a users session id, and would store the control collection during the current postback (and would be removed on prerender)

 

do you see any problems with this?

  • Administrators
Posted

Anything you put in the session will survive for 20 minutes by default and is designed to maintain state between postbacks.

If you do not require the object to persist over postbacks then there is no reason to use Sessions or any other form of state management - you could simply expose this collection as a property of the page / a shared class and allow access from multiple controls / modules.

You may want to search the internet for information of the Model / View / Control pattern as a source of one possible method.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
Anything you put in the session will survive for 20 minutes by default and is designed to maintain state between postbacks.

If you do not require the object to persist over postbacks then there is no reason to use Sessions or any other form of state management - you could simply expose this collection as a property of the page / a shared class and allow access from multiple controls / modules.

You may want to search the internet for information of the Model / View / Control pattern as a source of one possible method.

 

 

Ok, if i were to just expose the control collection as a property and then access it globally, how would I get the instance of the page when im in some random class?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...