<html>
<Script runat="server">
  Sub AddSession(sender As Object, e As EventArgs)
     Session("MySession") = text1.Value
     message.text = "Session Variable stored as  : " +Session("MySession").ToString() 
  End Sub

  Sub CheckVariable(sender As Object, e As EventArgs)
    If Session("MySession") = "" Then
          message.text  = "Session Data has been erased"
    Else
      message.text  = "Stored Session Variable is : " + Session("MySession").ToString() 
    End If
  End Sub
</Script>
<body style="font: 10pt verdana; background-color:ivory">
<h1> Session State </h1>
<form runat=server>
  <input id=text1 type=text runat=server><br><br>
  
 <asp:Button id="Add" text="Add Session Variable" onclick="addSession" runat="server" />
 <asp:Button id="Check" text="Check Session Variable" onclick="checkVariable" runat="server" /> 
 <hr>
 <asp:label id="message" runat="server" />	  
 </form>
</body>
</html>