charan kumar

charan kumar

  • 1.6k
  • 45
  • 5.2k

Using session in a proper way

Apr 12 2022 6:42 AM

Hi Guys , 
I am using session in vb.net . But when I go back to previous page and return to next page , changes are vanishing . Here I am trying to automatically check a check box in one page on particular dropdown option selection in previous page.

 

Here is what I ahve written:

page(1) where a dropdown selection has to be made:

--  'If nClassCode = 13454 Or nClassCode = 13455 Then--
            If nClassCode <> Nothing Then
                Session("classCode") = nClassCode
            End If
         --   'End If --

Page(2) where one checkbox should automatically be selected based on page(1) selection.

 Dim classcode As String = Session("classCode")
            If classcode = 13454 Or classcode = 13455 Then
                OptionalForms.CheckDefault()
            Else
                OptionalForms.Uncheck()
            End If
           -- 'Session.Remove("FirstName")--

Everything is working as excpeted except when I go back to page 1 and return to page 2 the checkbox that has been checked previously has now disappeared . Please help me on this . Thank You! Have a wonderful Day!

Note:   '--' indicates commeneted lines


Answers (2)