I cannot for the life of me figure out what I am doing wrong.
I want to capture a session for a checkbox, and if checked, send that to another page.
Code as follows:
First Page:
Second Page:Code:Private Function GetContact() As SortedList If Session("Contact") Is Nothing Then Session.Add("Contact", New SortedList) End If Return CType(Session("Contact"), SortedList) End Function Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click If chkContact.Checked = True Then Session.Add("Contact", New SortedList) Else chkContact.Checked = False End If Response.Redirect("results.aspx") End Sub
Code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load contact = Me.GetContact If Not IsPostBack Then Me.DisplayContact() Me.SetFocus("lblContact") End If End Sub Private Function GetContact() As SortedList If Session("Contact") Is Nothing Then Session.Add("Contact", New SortedList) End If Return CType(Session("Contact"), SortedList) End Function Private Sub DisplayContact() If Not IsPostBack Then lblContact.Text = "" Else lblContact.Text = "We will contact you within 24 hours" End If End Sub


Reply With Quote
Bookmarks