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.
Ok I managed to find a solution on my own thanks to all of your submissions, listen to this. I added a javascript function as follows:
and added an aspx file with the following code within it:
Basically this worked just fine, all I needed was a little jQuery. Thanks to all for your suggestions.