Session Question

  • Thread starter Thread starter Pete via DotNetMonster.com
  • Start date Start date
P

Pete via DotNetMonster.com

Hi,

I'm trying to use a Session variable to pass info from one page to another
but it doesn't seem to go to the next page. I tested a very basic script:

Page1
-----
<%@ Page Language="VB" %>
<script runat="server">

Sub page_load()

Session("name") = "James"
End Sub

</script>
<html>
<head>
</head>
<body>
Hello <%=Session("name")%>!
</body>
</html>

Page2
-----
<body>
Hello <%=Session("name")%>!
</body>

The name doesn't show up on the second page. Not sure what I'm missing.

Thanks
 
Hi!
What is wrong with your code and what error do you get if you get any at all?

Principally in session variables you save object rather than just strings
and you should use
Session("name").ToString()

Hope that helps!
Ragards,
Kostadin Kostov
 
FWIW
A string happens to be an object so its safe for storage as well.

--
Regards,
Alvin Bruney

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
------------------------------------------------------------
 
Back
Top