Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Variable Scope / Visibility

Reply
Thread Tools

Variable Scope / Visibility

 
 
Steve Wark
Guest
Posts: n/a
 
      05-23-2005
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








 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having trouble understanding function scope and variable scope Andrew Falanga Javascript 2 11-22-2008 09:23 PM
Scope visibility Kaba C++ 3 03-14-2006 03:31 AM
Variable Scope / Visibility / Caching Problem Steve Wark ASP .Net 1 05-23-2005 12:36 PM
Is "scope" different from "visibility" ? TTroy C Programming 8 02-14-2005 09:46 AM
How do I scope a variable if the variable name contains a variable? David Filmer Perl Misc 19 05-21-2004 03:55 PM



Advertisments