1

By using Jquery and commands like localStorage.setItem() and localStorage.getItem() I can pass parameters from a page to another one. But I don't know how i can use it in behind code. For example set them in variables and use them in methods. Do you have any idea?

Farhad
  • 205
  • 1
  • 6
  • 13
  • What do you mean behind code? Do you mean your server sided code? If so, you will probably need to post it to your server and use it. Or you can pass it through cookies, session variables etc. – Ravi Y Feb 18 '13 at 05:04
  • You know, `localStorage` is a DOM API and it has absolutely nothing to do with jQuery (save for some plugins). Your examples use nothing but pure JavaScript. – Fabrício Matté Feb 18 '13 at 05:04
  • http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage – Mithun Satheesh Feb 18 '13 at 05:06
  • I use of monodevelope as framework and C# as language programing. By behind code, I mean C# code which I am able to write behind the HTML code. – Farhad Feb 18 '13 at 05:32

1 Answers1

1

As LocalStorage is accessible only on client browser you can not access it's content from code behind ( ASP.NET, PHP, ... ). You will need to pass the content you want to use in code behind with one of the known methods like GET, POST, Cookies, ...

For instance you can do this:

document.location = "YourPage.aspx?data=" + localStorage.getItem ('whatever');

and then use something like this in your asp.net page load:

string data = Request.QueryString["data"];

and voila, you have what you need. I hope this helps.

Boynux
  • 5,958
  • 2
  • 21
  • 29