Passing values from one page to another in JavaScript
html, javascript
Solution
You cannot set a session with Javascript. Your output JS file will be exactly what you wrote down.
You can do it like this:
window.location = "WebForm2.aspx?temp=" + myvar;
And in Webform2 you can do:
Request.querystring["temp"];
Problem
In below code, the value is not passed from one page to another. ``` <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <script type="text/javascript"> function generateRow() { var myvar = "testuser"; '<%Session["temp"] = "' + myvar +'"; %>'; window.location = "WebForm2.aspx"; } </script> <head> <title></title> </head> <body> <div runat="server"> <input id="Button1" type="button" onclick="generateRow()" value="button" /> </div> </body> </html> ``` What is the problem in above code?