Nodes.Clear() is also erasing my session variables

  • Thread starter Thread starter Alex D.
  • Start date Start date
A

Alex D.

Hi. I have a TreeView stored in a session variable...is ok...problem is when
I use Nodes.Clear() then my session variable that holds the TreeView is also
emptied! Is this behavior by design or it's some kind of bug??

Thanks,

Alex.
 
See post from above. There is no logical reason
to store the control itself in session.
 
yes, by design.

if you use inproc sessions (the default), you a storing a reference to
control in session. if you make changes to the control, the changes are
reflected in session because its the same object. this is different than
value types.


string a = "hello";
string b = a; // b = "hello";
a = "bye"; // b still = "hello" because a now points to a new string

now lets look at objects

class test {
public string value = "hello";
}

test a = new test();
test b = a;
a.value = "bye"; // b.value = "bye", because a is not pointing to
a new object,
// a method was just called on the
common object
a = new test(); // make a point to new object
a.value = "more"; // b.value is still "bye", because a now points to
a new object


-- bruce (sqlwork.com)
 
yes...I dont know why I thougt that session variables were only values and
no references....thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top