473,796 Members | 2,625 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 20032
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
7074
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
8331
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
5979
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
25419
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
7341
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
3405
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
6636
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
10308
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
7222
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
9685
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
9531
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
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
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
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
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...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
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

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.