Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to set javascript variable value to Session Variable

How to set javascript variable value to Session Variable

Scheduled Pinned Locked Moved ASP.NET
javascripttutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    swapnilbhavsar
    wrote on last edited by
    #1

    Hello, I want to set javascript variable value to session variable in javascript. I am able to get Session Variable value to javascript variable as, <%string str="s2345";Session["Resolution"]=str;%> var Id=('<%=Session["Resolution"]%>'); But I want to set javascript variable value say screen.width to my Session Variable. Please let me know if someone knows the way Swapnil Bhavsar

    J N 2 Replies Last reply
    0
    • S swapnilbhavsar

      Hello, I want to set javascript variable value to session variable in javascript. I am able to get Session Variable value to javascript variable as, <%string str="s2345";Session["Resolution"]=str;%> var Id=('<%=Session["Resolution"]%>'); But I want to set javascript variable value say screen.width to my Session Variable. Please let me know if someone knows the way Swapnil Bhavsar

      J Offline
      J Offline
      John ph
      wrote on last edited by
      #2

      swapnilbhavsar wrote:

      I want to set javascript variable value to session variable in javascript.

      javascript runs on the client-side. session is a server-side object. you can't set javascript variable value to Session Variable in javascript.

      Regards
      J O H N :rose:
      "Even eagles need a push." David McNally


      1 Reply Last reply
      0
      • S swapnilbhavsar

        Hello, I want to set javascript variable value to session variable in javascript. I am able to get Session Variable value to javascript variable as, <%string str="s2345";Session["Resolution"]=str;%> var Id=('<%=Session["Resolution"]%>'); But I want to set javascript variable value say screen.width to my Session Variable. Please let me know if someone knows the way Swapnil Bhavsar

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        You have to pass the javascript variable to the server somehow, and set the session variable there. You can use AJAX methods, or some postback event to get the variable to the server.


        only two letters away from being an asset

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups