473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Assign Javascript value to asp session variable

Hi ,

I have the following javascript codes:
******************************************
<script language="JavaScript">
<!--
....
.....
if (nextRow >5)
{
<%Session("txtTotal")=%= nextRow;

for (var i=1; i<NewTotalRow; i++) {
<%

'session("txtBeginDT" & i) =
'session("txtEndDT" & i) = %>
}

}

....
....
// -->
</script>
******************************************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtTotal")=%= nextRow; ]
is this correct ?

regards
philin

Oct 9 '06 #1
4 19981
I assume this is a client side script. You won't have (at least directly)
access to session variables stored on the server when running client side
code.

A usual way to transmit client side computed values to the server is to
store them in hidden fields that will the be read server side on the next
submit (you need a server round trip whatever method you wan't to use)...

--
Patrice

<ph*******@gmail.coma écrit dans le message de news:
11**********************@k70g2000cwa.googlegroups. com...
Hi ,

I have the following javascript codes:
******************************************
<script language="JavaScript">
<!--
...
....
if (nextRow >5)
{
<%Session("txtTotal")=%= nextRow;

for (var i=1; i<NewTotalRow; i++) {
<%

'session("txtBeginDT" & i) =
'session("txtEndDT" & i) = %>
}

}

...
...
// -->
</script>
******************************************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtTotal")=%= nextRow; ]
is this correct ?

regards
philin

Oct 9 '06 #2

<ph*******@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hi ,

I have the following javascript codes:
******************************************
<script language="JavaScript">
<!--
...
....
if (nextRow >5)
{
<%Session("txtTotal")=%= nextRow;

for (var i=1; i<NewTotalRow; i++) {
<%

'session("txtBeginDT" & i) =
'session("txtEndDT" & i) = %>
}

}

...
...
// -->
</script>
******************************************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtTotal")=%= nextRow; ]
is this correct ?
No. Javascript in this case is running in the browser on the client. It
has no access to the session object which is on the server. Your need to
either include this value in a Form field that is submited to the server or
use another means to send the value from the client to the server. Perhaps
the best solution is to reconsider the design and remove this requirement
all together.
regards
philin

Oct 9 '06 #3
thanks guys..

i think i will have to use hidden fields..there are new methods like
ajax but not so familiar with it..Hidden fields the problem is the
value can be seen(right click view source) tats why I was thinkin of
using the session variable...looks like no other solution :)

Anthony Jones wrote:
<ph*******@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hi ,

I have the following javascript codes:
******************************************
<script language="JavaScript">
<!--
...
....
if (nextRow >5)
{
<%Session("txtTotal")=%= nextRow;

for (var i=1; i<NewTotalRow; i++) {
<%

'session("txtBeginDT" & i) =
'session("txtEndDT" & i) = %>
}

}

...
...
// -->
</script>
******************************************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtTotal")=%= nextRow; ]
is this correct ?

No. Javascript in this case is running in the browser on the client. It
has no access to the session object which is on the server. Your need to
either include this value in a Form field that is submited to the server or
use another means to send the value from the client to the server. Perhaps
the best solution is to reconsider the design and remove this requirement
all together.
regards
philin
Oct 9 '06 #4

<ph*******@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
thanks guys..

i think i will have to use hidden fields..there are new methods like
ajax but not so familiar with it..Hidden fields the problem is the
value can be seen(right click view source) tats why I was thinkin of
using the session variable...looks like no other solution :)
Being able to see internal values on the client is not a real problem.
There's nothing stopping the user debugging and single stepping your code.
So if you really do have something that a user must never be able to see, a
browser based solution is not for you.

>
Anthony Jones wrote:
<ph*******@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hi ,
>
I have the following javascript codes:
******************************************
<script language="JavaScript">
<!--
...
....
if (nextRow >5)
{
<%Session("txtTotal")=%= nextRow;
>
for (var i=1; i<NewTotalRow; i++) {
<%
>
'session("txtBeginDT" & i) =
'session("txtEndDT" & i) = %>
}
>
}
>
...
...
// -->
</script>
******************************************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtTotal")=%= nextRow; ]
is this correct ?
>
No. Javascript in this case is running in the browser on the client.
It
has no access to the session object which is on the server. Your need
to
either include this value in a Form field that is submited to the server
or
use another means to send the value from the client to the server.
Perhaps
the best solution is to reconsider the design and remove this
requirement
all together.
regards
philin
>

Oct 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
2
by: Matt | last post by:
If I assign VBScript server side variable a to javascript variable x, it is fine. <% Dim a, b a = 10 %> var x = <%= a %>; alert(x); But if I do the other way around, then it has 500 error....
3
by: M Wells | last post by:
Hi All, Just wondering how you go about changing the value of a session cookie via javascript? I have a PHP page that sets a session cookie when it first loads. I'd like to be able to change...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
3
by: Michelle Stone | last post by:
hi al i have "variab1 = window.open ("a.aspx", "helloworld"); i do this inside a RegisterStartupScrict ("key", "<script language=javascript>******</script>"); where ***** is hte javascript...
2
by: Mirovk | last post by:
Hi, I have a session variable wich value arrives from a previous .asp but in my actual page I need to modify it based upon a selected value from a radio button. I will try to figure out for...
12
by: Kurda Yon | last post by:
I am wandering which way to assign a value to a session variable exist. Which of the following examples will work. Example #1: session_start(); session_register("ex"); $ex = 2.0; Example...
5
by: aelred | last post by:
I have a web page where a member can open up a chat window (child window) with another member. - From there the member can also navigate to other web pages. - From other pages in the site, they...
2
by: rahullko05 | last post by:
i am stuck in the problem, where after user logs in successfuly, i take him to the login thanks page. now on that page i need to retain the login name. I am not sure how to this. i have written a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.