Save value in text box to session and read it back (VB.net/C#) : Session Variables « Sessions « ASP.NET Tutorial






<%@Page Language="VB" %>
<script runat="server">
   sub Submit_Click(Sender as Object,e as EventArgs)
      if tbName.Value <>""
         Session("Name ")=tbName.Value
         Response.Write("Hi " & Session("Name ")&"!")
      else
         Response.Write("You forgot to enter a name.")
      end if
   end sub
</script>

<html>
<body>
   <form runat="server">
      Please enter your name:
      <input type="text" id="tbName" runat="server"/>
      
      <asp:Button id="btSubmit" text="Submit" runat="server" OnClick="Submit_Click" />
   </form>
</body>
</html>
////////////////////////////

<%@ Page Language="VB" %>

<script runat="server">
   sub Page_Load(Sender as Object,e as EventArgs)
      Label1.Text ="Welcome back " & Session("Name ") & "!"
   end sub
</script>

<html><body>
   <form runat="server">
      <asp:Label id="Label1" runat="server"/>
   </form>
</body></html>

/////////////////////////////

<%@ Page Language="C#" %>

<script runat="server">
   void Page_Load(Object Sender, EventArgs e) {
      Label1.Text = "Welcome back " + Session["Name"] + "!";
   }
</script>

<html><body>
   <form runat="server">
      <asp:Label id="Label1" runat="server"/>
   </form>
</body></html>








11.3.Session Variables
11.3.1.Using Session State
11.3.2.Retrieve the value of an item that you have stored in Session state.
11.3.3.Sorting a DataView stored in Session state.
11.3.4.Save value in text box to session and read it back (VB.net/C#)
11.3.5.Save value to session object and read them back (VB.net)
11.3.6.Store user defined object in Session (C#)
11.3.7.Setting and retrieving objects from the Session using State Service and a base page (C#)
11.3.8.Setting and retrieving objects from the Session using State Service and a base page (VB)
11.3.9.A session-aware base page
11.3.10.Session counter and application counter (C#)
11.3.11.Session counter and application counter (VB)
11.3.12.Look for Variables