473,465 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Storing Controls as session variables?

is it possible? pros and cons?
Nov 23 '05 #1
12 4944
Don't forget that, if your clients browser disables cookies in his computer,
session will not be used by him.

"Alex D." <al********@hotmail.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
is it possible? pros and cons?

Nov 23 '05 #2
Why would you ever want to do this? I could see
storing the data used to populate the control
by why the entire control itself? Tons more
overhead with no additional benefit...

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
is it possible? pros and cons?

Nov 23 '05 #3
so..your answer is? yes or no?

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
Why would you ever want to do this? I could see
storing the data used to populate the control
by why the entire control itself? Tons more
overhead with no additional benefit...

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
is it possible? pros and cons?


Nov 23 '05 #4
The answer is both yes, and no. Yes you can store any object you want in
sessions, including control instances. But, upon return trips, the instance
you have in session will no longer map to the instance built when ASP.NET
constructs the object model, therefore, any changes made to the object in
session will not be reflected in the page output. The object model is
rebulit on each request.

"Alex D." <al********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
so..your answer is? yes or no?

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
Why would you ever want to do this? I could see
storing the data used to populate the control
by why the entire control itself? Tons more
overhead with no additional benefit...

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
is it possible? pros and cons?



Nov 23 '05 #5
but instead...the other way around any changes in the original control will
be reflected in the session object?? uhmmm
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
The answer is both yes, and no. Yes you can store any object you want in
sessions, including control instances. But, upon return trips, the
instance you have in session will no longer map to the instance built when
ASP.NET constructs the object model, therefore, any changes made to the
object in session will not be reflected in the page output. The object
model is rebulit on each request.

"Alex D." <al********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
so..your answer is? yes or no?

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
Why would you ever want to do this? I could see
storing the data used to populate the control
by why the entire control itself? Tons more
overhead with no additional benefit...

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
is it possible? pros and cons?



Nov 23 '05 #6
Obviously not if they do not reference the same object.

It might be something like the following example:

string strA = "hello world!";
string strB = strA;

//
// The two variables refer to the same object just as if you put a control
in the session.
//

strB = null;
strB = "hello world!";

//
// Just as with a page request, strB above is reset and although contains
the same content, they
// are two different objets in memory.
//

I would imaging the same thing happens with the object model. Changes made
in either are not seen by the other.
"Alex D." <al********@hotmail.com> wrote in message
news:OJ*************@TK2MSFTNGP10.phx.gbl...
but instead...the other way around any changes in the original control
will be reflected in the session object?? uhmmm
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
The answer is both yes, and no. Yes you can store any object you want in
sessions, including control instances. But, upon return trips, the
instance you have in session will no longer map to the instance built
when ASP.NET constructs the object model, therefore, any changes made to
the object in session will not be reflected in the page output. The
object model is rebulit on each request.

"Alex D." <al********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
so..your answer is? yes or no?

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
Why would you ever want to do this? I could see
storing the data used to populate the control
by why the entire control itself? Tons more
overhead with no additional benefit...

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
> is it possible? pros and cons?
>



Nov 23 '05 #7
No. Why would you want to store the entire control
in session? I can think of several negatives. What
would be the positive?

That said...

You'd have to research whether the controls
you are saving to session are serializable. If not,
you could never deploy your site in a web farm or
use anything but InProc on a single server.

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
so..your answer is? yes or no?

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
Why would you ever want to do this? I could see
storing the data used to populate the control
by why the entire control itself? Tons more
overhead with no additional benefit...

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
is it possible? pros and cons?



Nov 23 '05 #8
may be your example using strings is not the most appropriate in this case
because strings I think are considered a basic type so it is a value type
and not a reference.
and what it seems to me is that reference types are stored as references in
session variables, but instead of that what I needed was to save it as a
value type so I would be a different object.

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:Oz**************@tk2msftngp13.phx.gbl...
Obviously not if they do not reference the same object.

It might be something like the following example:

string strA = "hello world!";
string strB = strA;

//
// The two variables refer to the same object just as if you put a control
in the session.
//

strB = null;
strB = "hello world!";

//
// Just as with a page request, strB above is reset and although contains
the same content, they
// are two different objets in memory.
//

I would imaging the same thing happens with the object model. Changes
made in either are not seen by the other.
"Alex D." <al********@hotmail.com> wrote in message
news:OJ*************@TK2MSFTNGP10.phx.gbl...
but instead...the other way around any changes in the original control
will be reflected in the session object?? uhmmm
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
The answer is both yes, and no. Yes you can store any object you want
in sessions, including control instances. But, upon return trips, the
instance you have in session will no longer map to the instance built
when ASP.NET constructs the object model, therefore, any changes made to
the object in session will not be reflected in the page output. The
object model is rebulit on each request.

"Alex D." <al********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
so..your answer is? yes or no?

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
> Why would you ever want to do this? I could see
> storing the data used to populate the control
> by why the entire control itself? Tons more
> overhead with no additional benefit...
>
> --
> Robbe Morris - 2004/2005 Microsoft MVP C#
> http://www.masterado.net
>
>
>
>
>
> "Alex D." <al********@hotmail.com> wrote in message
> news:uy**************@TK2MSFTNGP14.phx.gbl...
>> is it possible? pros and cons?
>>
>
>



Nov 23 '05 #9
a simple use for a TreeView in a session variable is to keep the
collapsed/expanded info for every node when in the postback you redraw the
entire tree and loose all the properties...then you can restore this values
very easily in each postback. so your tree "remember" which nodes where
collapsed and which expanded...
of course there are many ways of doing this...actually I already used a
different approach...but in the session variable didnt work because just
after repopulating the tree also the session stored tree was affected and
all info erased.

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
No. Why would you want to store the entire control
in session? I can think of several negatives. What
would be the positive?

That said...

You'd have to research whether the controls
you are saving to session are serializable. If not,
you could never deploy your site in a web farm or
use anything but InProc on a single server.

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
so..your answer is? yes or no?

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
Why would you ever want to do this? I could see
storing the data used to populate the control
by why the entire control itself? Tons more
overhead with no additional benefit...

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"Alex D." <al********@hotmail.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
is it possible? pros and cons?



Nov 23 '05 #10
Hi, how did you implement the "remembering" of which nodes where
collapsed or expanded?? I'd love to know how you did this.

Thanks!
Henry

Dec 7 '05 #11
I didn't know as well.
I currently enum allnodes in a string(builder) "01011" etc.
Which i hold in the session
On page load i set these again.
<he***********@gmail.com> schreef in bericht
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi, how did you implement the "remembering" of which nodes where
collapsed or expanded?? I'd love to know how you did this.

Thanks!
Henry

Dec 7 '05 #12
AJ
Good answer

"Edwin Knoppert" <ne**@hellobasic.com> wrote in message
news:43**********************@text.nova.planet.nl. ..
I didn't know as well.
I currently enum allnodes in a string(builder) "01011" etc.
Which i hold in the session
On page load i set these again.
<he***********@gmail.com> schreef in bericht
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi, how did you implement the "remembering" of which nodes where
collapsed or expanded?? I'd love to know how you did this.

Thanks!
Henry


Dec 7 '05 #13

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

Similar topics

2
by: Jax | last post by:
Say for example a user of my website makes a selection on the site and I want to store that value for use on a later page what is the best way to do that? My only method at the moment that I know...
3
by: yop | last post by:
Hello I have an application, Login page, enter UserName & Password. Function in Users called GetUserDetails and checks the details and if they are valid calls a function to fill the following...
7
by: py | last post by:
how feasible is it to cache an entire page's content in a session variable? i am already doing it and it works fine, except i am afraid of scalability issues. what is the best way to test this? ...
3
by: foldface | last post by:
Hi I have the problem at the moment that I have to build a page with all its dynamic buttons etc in order to get postbacks on those buttons, then rebuild the control tree in response to any...
2
by: Curt tabor | last post by:
Hi, I have several pages in my app that all use the same oleDBConnection(s). When this connection gets created, I store it as a Session variable so that other pages can access it w/o having...
0
by: ben | last post by:
I am having some difficulty in understanding how to deal with variables, session states, objects, user controls while attempting to develop a ASP.Net application. I have created several user...
9
by: david | last post by:
I have a class with some business-logic and with every roundtrip, I need an instance of this class, so I have to create it, every time again. That doesn't seem very efficient. I thought it would...
4
by: =?Utf-8?B?YmFzdWxhc3o=?= | last post by:
Hi; I want to store a datatable (or an arraylist) as a session variable but when I try; Session = al_RecNo; I get an error that; "Cannot implicitly convert type...
6
by: J055 | last post by:
Hi I have the following code. I upload an XML file using the FileUpload object, store the stream in a session so the user gets the chance to confirm some options then pass the stream from the...
0
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,...
0
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,...
0
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
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 ...

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.