SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePοint Troll disgracian's Avatar
    Join Date
    Aug 2006
    Location
    Samsara
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:
    Code:
    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.

  2. #2
    SitePoint Member BigGuy's Avatar
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePοint Troll disgracian's Avatar
    Join Date
    Aug 2006
    Location
    Samsara
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •