How do I set a value to the Session in asp.net on an onClick event of a normal htmlElement?

Posted by William Calleja on Stack Overflow See other posts from Stack Overflow or by William Calleja
Published on 2010-03-17T15:23:24Z Indexed on 2010/03/17 15:31 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET