Friday 8 June 2012

Session in JavaScript


<script type="text/javascript">

function Setsession() {
    if (window.sessionStorage) {
       Var Val = document.getElementById(‘<%= Write.ClientID %>’).value;
       sessionStorage.setItem(“key1″, Value);              
    }
}

function GetSession() {
     if (window.sessionStorage) {
       Var Val = document.getElementById(‘<%= Get.ClientID %>’).value;
       Val   = sessionStorage.getItem(“key1″);
      }
}
  
</script>

Write this in HTML

 <asp:TextBox ID="Write" runat="server"></asp:TextBox>

 <asp:TextBox ID="Get" runat="server"></asp:TextBox>

 <asp:Button ID="btn" runat="server" Text = “Refresh Page/>

 <input type="button" onclick="Setsession();" value="set Value" />

 <input type="button" onclick="GetSession();" value="get Value" />

No comments:

Post a Comment