Writing session variables from Javascript

Hi all,

I’ve got an example of writing to session variables from a Javascript function that is as follows:

function someFunction(){
   '<%=Session["key"] = "Some Value" %>';
}

It works. What I can’t do is use a client-side variable instead of a literal string. If I break up the inline expression in any way, I end up with a syntax error. Can this be done?

Cheers,
D.

Maybe you could try having the JavaScript launch a window that will take a value from a hidden form field and post it. The aspx page could then take that value and set the session variable. You can then automatically close that window after it loads and is done.

There is probably a more elegant way, but I can’t think of it right now.

Sorry, I managed to resolve this one about 30 minutes after posting and forgot to come back and say so.

I did end up using a hidden field.

Cheers,
D.