Session save problem for Checkbox object (Pointer causing issue)

I am having a peculiar issue:

I am saving an object in my code behind (VB.NET) for a page as below:

         'UI Code:
         <asp:CheckBox ID="cbAddress" runat="server" Text="Check for Address Information"  Checked="false"/>

         'Code in the program
        Dim cbAddress As CheckBox = DirectCast(uclAddressInformation.FindControl("cbAddress"), CheckBox)
        SetCheckBoxToSession("cbAddress", cbAddress)

        'Function to SAVE/SET session
        Private Sub SetCheckBoxToSession(ByVal name As String, ByVal chk As CheckBox)
            HttpContext.Current.Session.Add(name, chk )
        End Sub

        'Function to GET session
        Private Function GetCheckBoxFromSession(ByVal name As String) As CheckBox
            Dim chk As New CheckBox
            Dim objChk As Object = HttpContext.Current.Session(key)

            If Not (objChk Is Nothing) Then
                chk = CType(objChk, CheckBox)
                Return Nothing
            End If

            Return (chk)

But when I read the session, after the checkbox is updated, the session value is also updated for Checkbox.Visible property. So it means that the session is storing a pointer to the object.

Is there any way to make snapshot of the object and then store the value in the session, so that the change in the object does not affect the session.

Note: I could have stored static values in the session that don't change, but I want to store the entire object.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


It's better to store value instead of complete server side element if you want to see an example for value please see this

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ArikkanAuthor Commented:
I could have stored static values in the session that don't change, but I want to store the entire object.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.