My goal is to create a link that will change a session variable upon onclick event, like so:
<a href="/Index" onclick="<% HttpContext.Current.Session["location"] = location;%>" >
<%=location%>
</a>
However, as the page processes, the session variable changes automatically while generating each anchor element with the onclick attribute. I attempted to solve this by creating a JavaScript function:
<script type="text/javascript" >
function session(location) {
HttpContext.Current.Session["location"] = location;
}
</script>
Unfortunately, my attempt doesn't seem to work. Any suggestions or ideas would be greatly appreciated. Thank you in advance.