473,395 Members | 1,919 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,395 software developers and data experts.

session variable unavailable?

I'm unable to access my session variables in a javascript function. Here
are the details:

In global.asa, I have the following:

Sub Session_OnStart
Session("TestMessage") = "Test One Two hree."
End Sub

I can set a break on the session("Test Message") line and confirm that it's
firing.

In my asp page, I have the following:

<script language="javascript">

function checkFields(theForm)
{
alert("TestMessage");
return false;
}

</script>

This is called by:

<FORM action="subscribe.asp" method=post id=form1 name=form1
onSubmit="return checkFields(this)">

First of all, I can't set any breaks on the javascript routine.

That aside, when configured as above, it works as expected, that is, I get
an alert message saying "TestMessage", so I know that the function is being
called. Since the function returns a value of false, subscribe.asp is not
loaded.

However, if I change that alert as follows:

alert(Session("TestMessage"));

The javascript function is apparently never called - I do not get the alert
message, and subscribe.asp is loaded.

Any ideas?


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Feb 18 '06 #1
1 1262
Joe Befumo wrote:
I'm unable to access my session variables in a javascript function. Here
are the details:

In global.asa, I have the following:

Sub Session_OnStart
Session("TestMessage") = "Test One Two hree."
End Sub

I can set a break on the session("Test Message") line and confirm
that it's firing.

In my asp page, I have the following:

<script language="javascript">

function checkFields(theForm)
{
alert("TestMessage");
return false;
}


You cannot directly access session variables in client-side code: this would
be quite a security breach wouldn't it?

What you can do is response.write the value of the session variable into
your html:

<script language="javascript">

function checkFields(theForm)
{
alert("<%=session("Test Message") %>");
return false;
}

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Feb 18 '06 #2

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

Similar topics

10
by: Hywel | last post by:
this script don't work Script A: set session variable <?php class Page0A { function Page0A(){ $this->init(); $this->save();
4
by: Jason Us | last post by:
Does anyone have experience with passing variables from an ASP page to a JSP page. The way it currently works in passing the SSN in the URL. This cannot be good. I thought that storing a...
0
by: Rick Strahl [MVP] | last post by:
Hi all, Has anybody run into this scenario: From within a page I use a Server.Transfer() to run another ASPX page. The other ASPX page however is not in the current directory but a sub of the...
4
by: T Ralya | last post by:
I am told that ASP.NET controls the session ID and session variables, but that does not fit my symptoms. I am posting here as directed. I'm hoping that someone can at least recommend something to...
9
by: Simon Smith | last post by:
Hi, I have a web application in which I need to restrict user access to 1 session per user. I've done this my creating a cache entry when a user logs in, and checking on subsequent logins for...
1
by: Flinky Wisty Pomm | last post by:
Hi all, I'm tearing my hair out here and I'm desperately hoping someone has a fix. I've got a .Net 2.0 web service for which I need session state, I can't use cookies because I'm using the...
2
by: Daflookie | last post by:
For one reason or another I am unable to access Session contents in my asp.net application via the global.asax's Application_Error event. I can pull this exact code snippet below out of...
8
by: Andrew Teece | last post by:
Hope someone can help. We are trying to deploy an ASP.Net 2.0 application to a 3-node webfarm. The application uses the ReportViewer control in local mode, hence we need session state. Because we...
22
by: Kurda Yon | last post by:
Hi, In the first page I declare a session variable. Than, on the same page, I make a form which contains a variable which has the same name as the mentioned session variable. Pressing the...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...

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.