Web
Analytics
HTML 5 Local and session storage simple example - Tutorial

For Consultation : +91 9887575540

Stay Connected :

Default1.aspx

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default1.aspx.cs” Inherits=”Default1″ %>

<!DOCTYPE html>

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title></title>
<script>
function LSIncrementCounter()
{
if (localStorage.Counter == null)
localStorage.Counter = 0;
localStorage.Counter = Number(localStorage.Counter) + 1;
document.getElementById(“divLSCounter”).innerHTML = localStorage.Counter;
}
function SSIncrementCounter() {
if (sessionStorage.Counter == null)
sessionStorage.Counter = 0;
sessionStorage.Counter = Number(sessionStorage.Counter) + 1;
document.getElementById(“divSSCounter”).innerHTML = sessionStorage.Counter;
}
</script>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<a href=”Default2.aspx”>Default2.aspx</a>
<hr />
<script>
if (typeof (Storage) == “undefined”)
document.write(“Web Storage is not supported”);
else
document.write(“Web Storage is supported”);
</script>
<hr />
Local Storage<div id=”divLSCounter”></div>
<br />
<input type=”button” name=”btnLSIncrementCounter” value=”LS – Increment Counter” onclick=”LSIncrementCounter()” />
<hr />
Session Storage<div id=”divSSCounter”></div>
<br />
<input type=”button” name=”btnSSIncrementCounter” value=”SS – Increment Counter” onclick=”SSIncrementCounter()” />
</div>
</form>
</body>
</html>

Select your currency