Re: Working with Cache and Viewstate
- From: Ryan Ternier <rternier@xxxxxxxxxxxxxxxx>
- Date: Thu, 16 Jun 2005 15:29:15 -0700
Hey David,
Thanks for the reply. That does make sense. I don't see a point in my work where I would need to do that, but it was interesting to find out it did that... and I wanted to know why.
Thanks :D
/RT David Lloyd wrote:
Ryan:
The ArrayList class inherits from System.Object with means it is a reference type. When you set the value of the ViewState variable, I believe you are passing a reference to the underlying ArrayList object rather than a copy of the object. Therefore any actions performed on the underlying object will affect the value in the ViewState.
All objects inheriting from System.Object inherit the MemberwiseClone method which makes a "shallow" copy of the object (value types are copied, but reference types just pass their reference). In order to have the ViewState remain unchanged in your scenario, you would need to make a copy of the object and assign it to the ViewState.
.
- References:
- Working with Cache and Viewstate
- From: Ryan Ternier
- Re: Working with Cache and Viewstate
- From: David Lloyd
- Working with Cache and Viewstate
- Prev by Date: Re: PostBack "Please Wait..." Message.
- Next by Date: Re: Preventing login as 'NT AUTHORITY\ANONYMOUS LOGON'
- Previous by thread: Re: Working with Cache and Viewstate
- Next by thread: adding extra code to the doPostBack function
- Index(es):
Relevant Pages
|