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. Session Varables and java script URGENT PLS

Session Varables and java script URGENT PLS

Scheduled Pinned Locked Moved ASP.NET
csharpjavajavascripthtmldatabase
8 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.
  • M Offline
    M Offline
    Masood Ahmed
    wrote on last edited by
    #1

    dear thnx for giving ur attention now i m telling u whole problem now what i wana do MAIN PROBLEM IS THAT can i access Session varables in java script or can i call javascript funcation in C# code or how i can pass array stored in session to javascript funcation 1-- i h funcation java script function ChangeDivPosition() { document.getElementById( "A").style.top+="370px"; return true; } </ script> A is id of Div html code is here <div id="A"; style="z-index: 101; left: 214px; width: 220px; position: relative; top: 0px; height: 82px;"12px" height: "43px" > <asp:Label ID="Label1" runat="server" Style="position: relative; left: 11px; top: 6px;" Text="A" Width="146px"></asp:Label> </div> now what i wana achieve that on page load just like that Page_Load() { for(int i=0;i<=5;i++) { //Call to java script funcation ChangeDivPosition() to move down the div and all control in it Label.text=Session["Array"].tostring(); // just wana tell u that i h to use session variables in java script } what i wana achieve in out put is just like that 1 370 px incerment 2 370 px incerment 3 370 px incerment 4 370 px incerment 5 i think now u might h clear vision abut my problem if u h solution of this or any other soltion to move the Div Down word on page load event tell me what u think abut its solution with server side java script i will be really gr8full to u thnx in advance Regards Masood </x-turndown>

    G M 2 Replies Last reply
    0
    • M Masood Ahmed

      dear thnx for giving ur attention now i m telling u whole problem now what i wana do MAIN PROBLEM IS THAT can i access Session varables in java script or can i call javascript funcation in C# code or how i can pass array stored in session to javascript funcation 1-- i h funcation java script function ChangeDivPosition() { document.getElementById( "A").style.top+="370px"; return true; } </ script> A is id of Div html code is here <div id="A"; style="z-index: 101; left: 214px; width: 220px; position: relative; top: 0px; height: 82px;"12px" height: "43px" > <asp:Label ID="Label1" runat="server" Style="position: relative; left: 11px; top: 6px;" Text="A" Width="146px"></asp:Label> </div> now what i wana achieve that on page load just like that Page_Load() { for(int i=0;i<=5;i++) { //Call to java script funcation ChangeDivPosition() to move down the div and all control in it Label.text=Session["Array"].tostring(); // just wana tell u that i h to use session variables in java script } what i wana achieve in out put is just like that 1 370 px incerment 2 370 px incerment 3 370 px incerment 4 370 px incerment 5 i think now u might h clear vision abut my problem if u h solution of this or any other soltion to move the Div Down word on page load event tell me what u think abut its solution with server side java script i will be really gr8full to u thnx in advance Regards Masood </x-turndown>

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

      Masood Ahmed wrote:

      can i access Session varables in java script

      No.

      Masood Ahmed wrote:

      or can i call javascript funcation in C# code

      No.

      Masood Ahmed wrote:

      or how i can pass array stored in session to javascript funcation

      You can't. Create javascript code that will create an array containing the data from the C# array.

      Masood Ahmed wrote:

      i think now u might h clear vision abut my problem

      No. I can't even see the code that you posted. Use the "Ignore HTML" function when posting code. And can you please try to write proper english, without all the "u wana h abut ur gr8full thnx" nonsense. This is not an SMS. --- b { font-weight: normal; }

      M C 2 Replies Last reply
      0
      • G Guffa

        Masood Ahmed wrote:

        can i access Session varables in java script

        No.

        Masood Ahmed wrote:

        or can i call javascript funcation in C# code

        No.

        Masood Ahmed wrote:

        or how i can pass array stored in session to javascript funcation

        You can't. Create javascript code that will create an array containing the data from the C# array.

        Masood Ahmed wrote:

        i think now u might h clear vision abut my problem

        No. I can't even see the code that you posted. Use the "Ignore HTML" function when posting code. And can you please try to write proper english, without all the "u wana h abut ur gr8full thnx" nonsense. This is not an SMS. --- b { font-weight: normal; }

        M Offline
        M Offline
        Masood Ahmed
        wrote on last edited by
        #3

        Sorry Brother For English i have used now i am sending u code hopefully ypu will be able to see html too now. function ChangeDivPosition() { document.getElementById( "A").style.top+="370px"; return true; } script> A is id of Div html code is here height: "43px" > now what i wana achieve that on page load just like that Page_Load() { for(int i=0;i<=5;i++) { //Call to java script funcation ChangeDivPosition() to move down the div and all control in it Label.text=Session["Array"].tostring(); // just wana tell u that i h to use session variables in java script } what i wana achieve in out put is just like that 1 370 px incerment 2 370 px incerment 3 370 px incerment 4 370 px incerment 5 what i got from your response that i stored the value of session array in an other array an then send this array to javascript funcation </x-turndown>

        G 1 Reply Last reply
        0
        • M Masood Ahmed

          dear thnx for giving ur attention now i m telling u whole problem now what i wana do MAIN PROBLEM IS THAT can i access Session varables in java script or can i call javascript funcation in C# code or how i can pass array stored in session to javascript funcation 1-- i h funcation java script function ChangeDivPosition() { document.getElementById( "A").style.top+="370px"; return true; } </ script> A is id of Div html code is here <div id="A"; style="z-index: 101; left: 214px; width: 220px; position: relative; top: 0px; height: 82px;"12px" height: "43px" > <asp:Label ID="Label1" runat="server" Style="position: relative; left: 11px; top: 6px;" Text="A" Width="146px"></asp:Label> </div> now what i wana achieve that on page load just like that Page_Load() { for(int i=0;i<=5;i++) { //Call to java script funcation ChangeDivPosition() to move down the div and all control in it Label.text=Session["Array"].tostring(); // just wana tell u that i h to use session variables in java script } what i wana achieve in out put is just like that 1 370 px incerment 2 370 px incerment 3 370 px incerment 4 370 px incerment 5 i think now u might h clear vision abut my problem if u h solution of this or any other soltion to move the Div Down word on page load event tell me what u think abut its solution with server side java script i will be really gr8full to u thnx in advance Regards Masood </x-turndown>

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Like Guffa said, you cannot directly access the Session object at the client side. You basically need to understand that the client side script (javascript) runs at the client side and the server side script (with C#) runs on the server machine, and you can mix them up. However, in your case you can make an out-of-box request to the server with an Ajax-style library such as AJAX.NET to access the Session object. You can find the sample code from the AJAX.NET site.

          G 1 Reply Last reply
          0
          • M Masood Ahmed

            Sorry Brother For English i have used now i am sending u code hopefully ypu will be able to see html too now. function ChangeDivPosition() { document.getElementById( "A").style.top+="370px"; return true; } script> A is id of Div html code is here height: "43px" > now what i wana achieve that on page load just like that Page_Load() { for(int i=0;i<=5;i++) { //Call to java script funcation ChangeDivPosition() to move down the div and all control in it Label.text=Session["Array"].tostring(); // just wana tell u that i h to use session variables in java script } what i wana achieve in out put is just like that 1 370 px incerment 2 370 px incerment 3 370 px incerment 4 370 px incerment 5 what i got from your response that i stored the value of session array in an other array an then send this array to javascript funcation </x-turndown>

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

            Nope. There is no html code. --- b { font-weight: normal; }

            1 Reply Last reply
            0
            • M minhpc_bk

              Like Guffa said, you cannot directly access the Session object at the client side. You basically need to understand that the client side script (javascript) runs at the client side and the server side script (with C#) runs on the server machine, and you can mix them up. However, in your case you can make an out-of-box request to the server with an Ajax-style library such as AJAX.NET to access the Session object. You can find the sample code from the AJAX.NET site.

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

              minhpc_bk wrote:

              you can make an out-of-box request to the server with an Ajax-style library

              That is a work-around, though. There already is a request when the page is loaded, and the information is available when the page is created, so there is no reason to make another request to get the information. --- b { font-weight: normal; }

              1 Reply Last reply
              0
              • G Guffa

                Masood Ahmed wrote:

                can i access Session varables in java script

                No.

                Masood Ahmed wrote:

                or can i call javascript funcation in C# code

                No.

                Masood Ahmed wrote:

                or how i can pass array stored in session to javascript funcation

                You can't. Create javascript code that will create an array containing the data from the C# array.

                Masood Ahmed wrote:

                i think now u might h clear vision abut my problem

                No. I can't even see the code that you posted. Use the "Ignore HTML" function when posting code. And can you please try to write proper english, without all the "u wana h abut ur gr8full thnx" nonsense. This is not an SMS. --- b { font-weight: normal; }

                C Offline
                C Offline
                cloudking11966
                wrote on last edited by
                #7

                hey you can access Session variable in Javascript give var empid="<%=Session("EMPID")%>"; but take care that session has proper value

                G 1 Reply Last reply
                0
                • C cloudking11966

                  hey you can access Session variable in Javascript give var empid="<%=Session("EMPID")%>"; but take care that session has proper value

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

                  sebastiansony11966 wrote:

                  hey you can access Session variable in Javascript

                  That statement is not true. It's impossible to access a session variable from Javascript. What you give an example of, is how to get the value from the session variable and use it to create Javascript code that will create a variable that has the same value. --- 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