Session variables not working

A

Andy B.

I have the following code inside of a DataList.Item_Created event (in a
web user control):
If (e.Item.ItemType = ListItemType.Header) Then
Dim TitleTextBox As TextBox =
DirectCast(e.Item.FindControl("TitleTextBox"), TextBox)
Dim DescriptionTextBox As TextBox =
DirectCast(e.Item.FindControl("DescriptionTextBox"), TextBox)
Dim BodyTextBox As TextBox =
DirectCast(e.Item.FindControl("BodyTextBox"), TextBox)

'*** Save in session for use on next page
Session("NewsTitle") = TitleTextBox.Text
Session("NewsBody") = BodyTextBox.Text
Session("NewsDescription") = DescriptionTextBox.Text
Session("NewsCreationDate") = Date.Now
End If

I then have a button click event that has this in it:
Server.Transfer("file.aspx")

My problem is when I do this on the next page, I only get the date
created above. This is what I do in the target page:

Dim Title As String = DirectCast(Session("NewsTitle"), String)
Dim Description As String = DirectCast(Session("NewsDescription"), String)
Dim Body As String = DirectCast(Session("NewsBody"), String)
Dim CreationDate As Date = DirectCast(Session("NewsCreationDate"), Date)


Response.Write(Title)
Response.Write(Description)
Response.Write(Body)
Response.Write(CreationDate.ToString("f"))

Any idea what could be going wrong and how I can fix it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,888
Messages
2,569,964
Members
46,293
Latest member
BonnieHamb

Latest Threads

Top