473,883 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assign Javascript value to asp session variable

Hi ,

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

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

'session("txtBe ginDT" & i) =
'session("txtEn dDT" & i) = %>
}

}

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

regards
philin

Oct 9 '06 #1
4 20040
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*******@gmai l.coma écrit dans le message de news:
11************* *********@k70g2 00...legr oups.com...
Hi ,

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

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

'session("txtBe ginDT" & i) =
'session("txtEn dDT" & i) = %>
}

}

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

regards
philin

Oct 9 '06 #2

<ph*******@gmai l.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hi ,

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

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

'session("txtBe ginDT" & i) =
'session("txtEn dDT" & i) = %>
}

}

...
...
// -->
</script>
*************** *************** ************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtT otal")=%= 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...look s like no other solution :)

Anthony Jones wrote:
<ph*******@gmai l.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hi ,

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

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

'session("txtBe ginDT" & i) =
'session("txtEn dDT" & i) = %>
}

}

...
...
// -->
</script>
*************** *************** ************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtT otal")=%= 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*******@gmai l.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.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...look s 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*******@gmai l.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hi ,
>
I have the following javascript codes:
*************** *************** ************
<script language="JavaS cript">
<!--
...
....
if (nextRow >5)
{
<%Session("txtT otal")=%= nextRow;
>
for (var i=1; i<NewTotalRow; i++) {
<%
>
'session("txtBe ginDT" & i) =
'session("txtEn dDT" & i) = %>
}
>
}
>
...
...
// -->
</script>
*************** *************** ************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtT otal")=%= 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
7076
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 simple/advanced html forms and how it can be used to override cookie/session
2
8333
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. any ideas??
3
5983
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 the value of that session cookie in response to a button click in a form, without resubmitting the page. For some reason, the following doesn't seem to work:
16
25431
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 the properties: mode1, mode2, and mode3. This seems simple but I can't quite figure it out... Any ideas anyone?
3
7349
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 comman i need to access variab1 from some other forms (to close it from another link from the parent's parent's parent's page). i figured out that the best way to do this is to store this javascript variable in a session variable now comes the...
2
3407
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 better understanding: page1.asp ---session("PaymentMethod") page2.asp ---Depending on the radio button selected the payment
12
6643
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 #2: In first.php:
5
10317
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 may also open up new chat windows with other members (just not the same one). - Each chat page is opened with the member name as the window name. - When I log off from the web page, I would like all the chat windows to automatically close. I...
2
7226
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 query string which passes the SID from this page. <a href="loginthanks.php?<?php echo htmlspecialchars(SID); ?>" > now how can i send the login name to next page. Also i want to store this value of login name in some session variable, so...
0
9953
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10868
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9588
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4231
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3242
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.