Variable Scope / Visibility

Discussion in 'ASP .Net' started by Steve Wark, May 23, 2005.

  1. Steve Wark

    Steve Wark Guest

    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
     
    Steve Wark, May 23, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Wark
    Replies:
    1
    Views:
    608
    Brock Allen
    May 23, 2005
  2. TTroy

    Is "scope" different from "visibility" ?

    TTroy, Feb 10, 2005, in forum: C Programming
    Replies:
    8
    Views:
    324
    Dave Thompson
    Feb 14, 2005
  3. Kaba

    Scope visibility

    Kaba, Mar 13, 2006, in forum: C++
    Replies:
    3
    Views:
    362
    Greg Comeau
    Mar 14, 2006
  4. David Filmer
    Replies:
    19
    Views:
    267
    Kevin Collins
    May 21, 2004
  5. Andrew Falanga
    Replies:
    2
    Views:
    208
    Andrew Falanga
    Nov 22, 2008
Loading...

Share This Page