.Net Interview Questions and Answers

Search:

How can we add and remove data from local storage?(ASP.NET HTML 5 interview questions)

By : Shiv Prasad Koirala | Dec 11th, 2013 | Views : 2446 | Comments : 0 Bookmark and Share

Data is added to local storage using "key" and "value". Below sample code shows country data "India" added with key value "Key001".


localStorage.setItem("Key001","India");


To retrieve data from local storage we need to use "getItem" providing the key name.


var country = localStorage.getItem("Key001");


You can also store JavaScript object's in the local storage using the below code.


var country = };

country.name = "India";

country.code = "I001";

localStorage.setItem("I001", country);

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.


localStorage.setItem("I001",JSON.stringify(country));



What is the lifetime of local storage?


Local storage does not have a life time it will stay until either the user clear it from the browser or you remove it using JavaScript code.


Below is a ASP.NET interview question with answer video which explains how response.redirect is different from server.transfer.


 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi