How can we add and remove data from local storage?(ASP.NET HTML 5 interview questions)
- By Shiv Prasad Koirala in ASP.NET
- Dec 11th, 2013
Data is added to local storage using "key" and "value". Below sample code shows country data "India" added with key value "Key001".
To retrieve data from local storage we need to use "getItem" providing the key name.
var country = localStorage.getItem("Key001");
var country = };
country.name = "India";
country.code = "I001";
var country1 = localStorage.getItem("I001");
If you want to store in JSON format you can use "JSON.stringify" function as shown in the below code.
What is the lifetime of local storage?
Below is a ASP.NET interview question with answer video which explains how response.redirect is different from server.transfer.
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more