1

I am developing Windows phone 7.1 PhoneGap app. I would like to remove localstorage which was created by window.localStorage.setItem JavaScript code in C#. I know, in JavaScript we can remove using window.localStorage.removeItem. But, I want to remove from code behind C#. Any help is appreciated.

  • Are you using a WebBrowser control? http://stackoverflow.com/questions/153748/how-to-inject-javascript-in-webbrowser-control – sq33G Jun 13 '13 at 12:00
  • I tried WebBrowser, But some unknown error occurs with exception. –  Jun 13 '13 at 12:03

1 Answers1

6

Use this code,

ScriptManager.RegisterStartupScript(this, GetType(), "YourUniqueScriptKey", 
        "localStorage.removeItem(key);", true);

note: local storage is a client side and C# is serverside. so simple you cannot access client side items with c#. but in above code it will run a javascript code in the first page load after your c# event.

Chamika Sandamal
  • 23,565
  • 5
  • 63
  • 86