2
Answers

Using session in a proper way

charan kumar

charan kumar

3y
744
1

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)
0
Uttam Kumar

Uttam Kumar

535 2.3k 285k 3y
Can you check what are you getting in session when you return to page2? If you do not get session value on returning to page2 then you have to check the flow for session by keeping in quick watch upon return in page1. I hope this should help you..
0
Gajendra Jangid

Gajendra Jangid

25 41.2k 2.3m 3y
try this link
https://www.c-sharpcorner.com/UploadFile/225740/introduction-of-session-in-Asp-Net/