Variable Scope / Visibility

S

Steve Wark

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,height=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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top