How do I set a value to the Session in asp.net on an onClick event of a normal htmlElement?
- by William Calleja
I need to make a Function that receives a Session Key and a Session Value and call this function on a normal HTML onClick event. When this function is called the Session variable is assigned the Key I sent with the Value I sent. So far I have this:
<script runat="server" type="text/C#">
protected void setSessionValue(string key, string value)
{
Session[key] = value;
}
</script>
But when I try to call if like so:
onclick="setSessionValue('itemID','3345');"
Its not working and giving me an error. Any help? I'm using c# and asp.net but I can't use code behind and need to work everything off the page.