473,769 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles MyBase.Load

Response.Expire s = -1

Button1.Attribu tes.Add("onClic k",
"window.open('w ebform2.aspx',' Title','width=9 50,height=610,l eft=100,top=100 ')")

End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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.EventArg s) Handles MyBase.Load

Response.Expire s = -1

Button1.Attribu tes.Add("onClic k", "window.close() ")

TextBox1.Text = v1

TextBox2.Text = Application("v2 ")

TextBox3.Text = Session("v3")

End Sub



Nov 19 '05 #1
1 1788
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.EventArg s) Handles MyBase.Load
Response.Expire s = -1

Button1.Attribu tes.Add("onClic k",
"window.open('w ebform2.aspx',' Title','width=9 50,height=610,l eft=100,to
p=100')")
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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.EventArg s) Handles MyBase.Load
Response.Expire s = -1

Button1.Attribu tes.Add("onClic k", "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
3195
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
3378
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 actual program. To me "scope" of the name of a function or object are the general rules for the areas of a program that can through a declaration, have "visibility."
14
2423
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 be declared as auto or anything else?
0
1254
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 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...
6
2154
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, criticism, advices, improvements. Abbreviation: Created (C)
8
12621
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. The code below draws an error as indicated. Surely there has to be a better way than to make xxx a session variable? Thanks
10
12805
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 involving variable scope in JavaScript.) I have a lot of code that generates HTML on the fly. This code has tags with id attributes derived from variables. A small example: blah('<span id="' + dev + '_' + mod + '">...</span>');
5
2238
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
5475
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 that may print some messages. foo(...) { if (!silent)
0
9423
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
10212
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...
0
9863
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
8872
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
7410
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
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.