Session Varables and java script URGENT PLS
-
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>
-
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>
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; }
-
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; }
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>
-
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>
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.
-
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>
-
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.
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; }
-
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; }
hey you can access Session variable in Javascript give var empid="<%=Session("EMPID")%>"; but take care that session has proper value
-
hey you can access Session variable in Javascript give var empid="<%=Session("EMPID")%>"; but take care that session has proper value
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; }