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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to access to a javascript variable from code behind ? [modified]

How to access to a javascript variable from code behind ? [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripttutorialquestion
4 Posts 4 Posters 1 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.
  • A Offline
    A Offline
    amin_behzadi
    wrote on last edited by
    #1

    Hi I declared a global variable in my .aspx file as : var Myvar=new Object(); and I want to access this var in code behind .... !???? www.behzadi.net -- modified at 6:27 Tuesday 30th May, 2006

    _ M G 3 Replies Last reply
    0
    • A amin_behzadi

      Hi I declared a global variable in my .aspx file as : var Myvar=new Object(); and I want to access this var in code behind .... !???? www.behzadi.net -- modified at 6:27 Tuesday 30th May, 2006

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      Hi, you can put this in hidden field and then can use it in code behind page. Best Regards, Apurva Kaushal

      1 Reply Last reply
      0
      • A amin_behzadi

        Hi I declared a global variable in my .aspx file as : var Myvar=new Object(); and I want to access this var in code behind .... !???? www.behzadi.net -- modified at 6:27 Tuesday 30th May, 2006

        M Offline
        M Offline
        Malik Nasir
        wrote on last edited by
        #3

        you can not do this as java variable will be a client side variable and in code behind u can access the serverside variables so the only way is get the value of thatt variable in some hidden server side variable then u will be able to get the value. Regards

        1 Reply Last reply
        0
        • A amin_behzadi

          Hi I declared a global variable in my .aspx file as : var Myvar=new Object(); and I want to access this var in code behind .... !???? www.behzadi.net -- modified at 6:27 Tuesday 30th May, 2006

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Consider these two rules: 1. The server side code and the client side code never exist in the same place. 2. The server side code and the client side code never exist at the same time. The Javascript variable that you created doesn't exist until the page reaches the browser, and then the server side code is already finished. While the server side code is running, the Javascript you have written is just handled as plain text. You can use server code to put a value in the page that can be used by the client code once the page is loaded in the browser, and you can send a value back from the client script in the next postback. Everything between the server and the client is sent as text. You can't send an object between the server and the client. --- b { font-weight: normal; }

          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