As in question. Is it possible to set variable in asp.net page in localStorage and retrieve it on the other page?
How to set localStorage variable in asp.net. Is it possible? After that I could read variable using:
localStorage.getItem('UserID');
Since we can set up javascript code in asp.net and insert into the client side, there's no difference with the session or local storage. That will set the session (you could do local) storage variable to the value 12345.
I think setting session variable in page & read variable in javascript of another page is possible. But, if you are looking out for localstorage that won't be. It needs javascript. For session variable e.g.
Local storage isn't ASP.NET, it's a web browser API. You use javascript to work with it. As to your Session question, you can always make a request to the server to get any value you might generally want, if you've built something to answer those requests.
Web storage objects localStorage and sessionStorage allow to save key/value pairs in the browser. What’s interesting about them is that the data survives a page refresh (for sessionStorage) and even a full browser restart (for localStorage ).
I think setting session variable in page & read variable in javascript of another page is possible. But, if you are looking out for localstorage that won't be. It needs javascript. For session variable e.g.
A.aspx
<% Session["username"]="Donald Duck"; %>
B.aspx
> <script type="text/javascript">
> var user = "<%= Session["username"] %>";
> document.write(user);
> </script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With