473,398 Members | 2,165 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,398 software developers and data experts.

Variable Scope / Visibility / Caching Problem

If I create two aspx pages, place three text boxes (working with VS .net
2003 and web form controls) and a button on both forms.

On the first page, the button is set to use the "onClick" to open the second
page using Window.Open with the values being passed to the second page by a
global variable created in a Module added to the project, by the use of an
Application variable and by the use of a session variable.

In the page load of the second form the values of the text boxes are set to
these passed values.

When I run this as a single instance all works fine. If from another
machine I now open this web site, while still having the first instance open
then the data displayed on the second page reflects the first instances data
for the global variable and the application variable, the session variables
data is blank. If I right click and perform a refresh the data become
correct.

I assume this must be something to do with caching.

Can anyone advise?

Steve Wark
First Pages Page_Load & Button Click
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.Expires = -1

Button1.Attributes.Add("onClick",
"window.open('webform2.aspx','Title','width=950,he ight=610,left=100,top=100')")

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

v1 = TextBox1.Text

Application("v2") = TextBox2.Text

Session("v3") = TextBox3.Text

End Sub
Second Pages Page_Load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.Expires = -1

Button1.Attributes.Add("onClick", "window.close()")

TextBox1.Text = v1

TextBox2.Text = Application("v2")

TextBox3.Text = Session("v3")

End Sub



Nov 19 '05 #1
1 1762
This approach won't work in a multi-user scenario. The variables you put
into the module are in fact global for all users of your ASP.NET web application.
You should look into using something like Session state to maintain per-user
data. Here's a list of state management options (including Session):

http://msdn.microsoft.com/library/de...asp?frame=true

-Brock
DevelopMentor
http://staff.develop.com/ballen
If I create two aspx pages, place three text boxes (working with VS
.net 2003 and web form controls) and a button on both forms.

On the first page, the button is set to use the "onClick" to open the
second page using Window.Open with the values being passed to the
second page by a global variable created in a Module added to the
project, by the use of an Application variable and by the use of a
session variable.

In the page load of the second form the values of the text boxes are
set to these passed values.

When I run this as a single instance all works fine. If from another
machine I now open this web site, while still having the first
instance open then the data displayed on the second page reflects the
first instances data for the global variable and the application
variable, the session variables data is blank. If I right click and
perform a refresh the data become correct.

I assume this must be something to do with caching.

Can anyone advise?

Steve Wark

First Pages Page_Load & Button Click
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Expires = -1

Button1.Attributes.Add("onClick",
"window.open('webform2.aspx','Title','width=950,he ight=610,left=100,to
p=100')")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

v1 = TextBox1.Text

Application("v2") = TextBox2.Text

Session("v3") = TextBox3.Text

End Sub

Second Pages Page_Load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Expires = -1

Button1.Attributes.Add("onClick", "window.close()")

TextBox1.Text = v1

TextBox2.Text = Application("v2")

TextBox3.Text = Session("v3")

End Sub


Nov 19 '05 #2

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

Similar topics

6
by: Brian Jones | last post by:
I'm sure the solution may be obvious, but this problem is driving me mad. The following is my code: class a(object): mastervar = def __init__(self): print 'called a'
8
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an...
14
by: rahul8143 | last post by:
hello, To limit scope of a variable in a single file that is part of a large project that have several C files we use static variable right?then to limit any variable to function scope it should...
0
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open...
6
by: Neelesh Bodas | last post by:
Hello All, I was just listing down various ways in which variables can be created and destroyed in C++. (On the lines of 10.4.3 TC++PL Ed 3) Putting the summary here for corrections, comments,...
8
by: Jeff | last post by:
Still new to vb.net in VS2005 web developer... What is the proper/standard way of doing the following - setting the value of a variable in one sub and calling it from another? E.g., as below....
10
by: John Passaniti | last post by:
(Note: This is not the same message I posted a week or so ago. The problem that prevented my previous attempt to work was a silly error in the template system I was using. This is a problem...
5
by: somenath | last post by:
Hi All , I have one question regarding scope and lifetime of variable. #include <stdio.h> int main(int argc, char *argv) { int *intp = NULL; char *sptr = NULL;
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
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...

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.