Set session variables

Discussion in 'ASP General' started by DS, Dec 3, 2003.

  1. DS

    DS Guest

    In client-side script (<script> codes </script>), how can set / get session
    variables' values? Pls advise.

    DS
     
    DS, Dec 3, 2003
    #1
    1. Advertisements

  2. Hi,

    If your are using JavaScript, you can assign the value for ur ASP session variable into a JavaScript variable and then work on it.
    Like

    <script>
    var name;
    name = "<%=Session("name")%>"
    ........

    </script>

    Bhaskardeep Khaund
     
    Bhaskardeep Khaund, Dec 3, 2003
    #2
    1. Advertisements

  3. DS

    DS Guest

    But, how can I assign a variable or values to a session variable within a client-side script? For example

    <script>
    //Java script
    document.write ("<%Session("ItemCode") = " + strTest + "%>")
    </script>
    Any wrongs here?

    DS
    "Bhaskardeep Khaund" <> 在郵件 news: 中撰寫...
    Hi,

    If your are using JavaScript, you can assign the value for ur ASP session variable into a JavaScript variable and then work on it.
    Like

    <script>
    var name;
    name = "<%=Session("name")%>"
    .......

    </script>

    Bhaskardeep Khaund
     
    DS, Dec 4, 2003
    #3
  4. Hi,

    How can you assign a Session variable to a client-side variable. Since, session would be executed on the server-side and your JS scripts would be executed on the clients computer. I think u cant do that.

    Bhaksardeep Khaund
     
    Bhaskardeep Khaund, Dec 4, 2003
    #4
  5. DS

    DS Guest

    Then, how can I pass a value, which is got in client-side, to server-side? Can I call a client-side function, which returns a value, in server-side script? Actually, I am in trouble on how to communicate between client and server sides script very well....please advise.

    Thanks,
    DS
    "Bhaskardeep Khaund" <> 在郵件 news:eQo67% 中撰寫...
    Hi,

    How can you assign a Session variable to a client-side variable. Since, session would be executed on the server-side and your JS scripts would be executed on the clients computer. I think u cant do that.

    Bhaksardeep Khaund
     
    DS, Dec 4, 2003
    #5
  6. DS

    Bob Barrows Guest

    DS wrote:
    > In client-side script (<script> codes </script>), how can set / get
    > session variables' values? Pls advise.
    >
    > DS


    There was a technique posted sometime in the last couple weeks for setting a
    session variable via an IMG tag on the page. I'll see if I can find it
    later.

    In the meantime, you can also use XMLHTTP to pass a value to a server-side
    page which can then set a session variable. A Google search, or a visit to
    www.aspfaq.com, should provide you with a few examples.


    To pass a session variable's value to client-side script, simply
    response.write it:

    client_side_var = "<%=session("var")%>"

    HTH,
    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Dec 4, 2003
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Earl Teigrob

    Global Session Variables and Session State

    Earl Teigrob, Dec 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    4,941
    Alvin Bruney
    Dec 17, 2003
  2. Michaeld

    session variables not set

    Michaeld, May 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    485
    Michaeld
    May 11, 2004
  3. Magnus Blomberg

    Can't set session variables

    Magnus Blomberg, Aug 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    550
    Eliyahu Goldin
    Aug 30, 2004
  4. =?iso-8859-15?Q?Fabr=EDcio_de_Novaes_Kucinskis?=

    Session Variables assigned to the wrong session?

    =?iso-8859-15?Q?Fabr=EDcio_de_Novaes_Kucinskis?=, Jan 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    839
    Alvin Bruney [MVP]
    Jan 20, 2005
  5. Chris Newby
    Replies:
    2
    Views:
    7,084
    Steve C. Orr [MVP, MCSD]
    Apr 23, 2005
  6. Michael
    Replies:
    3
    Views:
    1,296
    Jim Cheshire
    Dec 30, 2005
  7. Replies:
    1
    Views:
    1,106
  8. Replies:
    9
    Views:
    1,294
Loading...