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. calling session["id"] from javascript

calling session["id"] from javascript

Scheduled Pinned Locked Moved Web Development
csharpjavascriptquestion
7 Posts 4 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.
  • H Offline
    H Offline
    haytham_mohammad
    wrote on last edited by
    #1

    i have a session["id"] in c# code behind file, i want to read this session from javascript. how can i do it thanks in advance.

    haitham

    W V R 3 Replies Last reply
    0
    • H haytham_mohammad

      i have a session["id"] in c# code behind file, i want to read this session from javascript. how can i do it thanks in advance.

      haitham

      W Offline
      W Offline
      WoutL
      wrote on last edited by
      #2

      You can place the value of session["id"] in a hidden textbox in the code behind file. You can access the value of this textbox in javascript.

      Wout Louwers

      H 1 Reply Last reply
      0
      • H haytham_mohammad

        i have a session["id"] in c# code behind file, i want to read this session from javascript. how can i do it thanks in advance.

        haitham

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        You can assign this to a JavaScript variable and then use it.

        Vasudevan Deepak Kumar Personal Homepage Tech Gossips

        H 1 Reply Last reply
        0
        • W WoutL

          You can place the value of session["id"] in a hidden textbox in the code behind file. You can access the value of this textbox in javascript.

          Wout Louwers

          H Offline
          H Offline
          haytham_mohammad
          wrote on last edited by
          #4

          first thanking for your reply. if you hide the textbox and then read the value of this textbox from javascript, it is fail , it is succeeded only if the control is visible i made it using this line document.getelementById("controlid"). thanks

          haitham

          W 1 Reply Last reply
          0
          • V Vasudevan Deepak Kumar

            You can assign this to a JavaScript variable and then use it.

            Vasudevan Deepak Kumar Personal Homepage Tech Gossips

            H Offline
            H Offline
            haytham_mohammad
            wrote on last edited by
            #5

            thanks for ur attention to reply me the problem in accessing variable in code behind file from javascript thanks.

            haitham

            1 Reply Last reply
            0
            • H haytham_mohammad

              first thanking for your reply. if you hide the textbox and then read the value of this textbox from javascript, it is fail , it is succeeded only if the control is visible i made it using this line document.getelementById("controlid"). thanks

              haitham

              W Offline
              W Offline
              WoutL
              wrote on last edited by
              #6

              Yhis is true if you set the visible property to false. If you set the visisble property to true, and the type property to hidden, it should do the job.

              Wout Louwers

              1 Reply Last reply
              0
              • H haytham_mohammad

                i have a session["id"] in c# code behind file, i want to read this session from javascript. how can i do it thanks in advance.

                haitham

                R Offline
                R Offline
                RichardGrimmer
                wrote on last edited by
                #7

                Unfortunately, you can't get js to talk to the server unless you use AJAX....the way to get around it is to use asp:HiddenFields on your page. If you need access to a server side variable, store it in one when you process on the server, then at the client, use document.getElementById to retrieve the value...

                "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

                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