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. Advertising

  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. Advertising

  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. Advertising

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. Mark Rodrigues

    Re: Session variables set to nothing??

    Mark Rodrigues, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    398
    Mark Rodrigues
    Oct 29, 2003
  2. Michaeld

    session variables not set

    Michaeld, May 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    427
    Michaeld
    May 11, 2004
  3. Michael Michael

    RE: session variables not set

    Michael Michael, May 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    394
    Michael Michael
    May 12, 2004
  4. Replies:
    1
    Views:
    959
  5. Replies:
    9
    Views:
    997
Loading...

Share This Page