I have this code:
<a href="index.asp" onclick="<%Session("example") = True%>">LINK</a>
The problem is that this result in the session example will be true when loading this page and not when clicking on the link.
How can I solve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
All the server code in the page runs on the server before the page is sent to the browser. What you end up with in the browser is just:
If you want to run server code when an event happens in the browser, you have to make another request to the server. You can either make a postback of the page and send some information back to the server (in querystring/formdata/cookie), or use AJAX to request a different page that contains the server code that you want to run.
Edit:
To use a querystring, make a reload of the same page and add for example
?ex=1to the URL. In the server code you can check for this and set the session: