Using variables in asp.net using vb.net within the same page as page declared RRS feed

  • Question

  •   I have an interest inventory which I developed for Windows that I am trying to convert to run on the web. I have a presentation page which presents 2 activites (of different areas of interest) at a time with a picture of each and a button under each picture describing the activity with the text property of the button. I have a label on the page that indicates the frame number(there are 60 frames). Each frame allows the individual to choose one of the activities by clicking on the button under the activity. There are 6 areas of interest as defined by career guidance researchers. As the individual progresses through the frames the program must accumulate a count of the selections within each area of interest. The frames are all presented on the same aspx page (present.aspx). When a selection is made on a frame, new pictures are loaded into the LPic and RPic .image properties and the appropriate text is placed on the button under the activity.

      I have encountered a problem in using the variables to hold the count of the selections within each interest area. I declared the variables that I need to use for the accumulation of the data within the load statement. I changed 'Protected' to 'Public' hoping that would make them available to all the objects on the page, but I cannot seem to make it work. I can understand why variable data is not available across pages without special manipulation, but I do not get why data on the same page is not available to all the objects on that page.

      This is probably so simple that you will think I should not even be trying to do this if I cannot understand such a simple thing. I thought my difficulty would be in writing the data to my SQL database and searching for the proper report based on the interest profile. If I ever get over this obstacle then I will probably need to get some help with that problem. Right now I just need someone to help me with this very simple problem.

      I have read much of the information in the forum about moving variable content from page to page, but I just cannot find information about this simple proceedure.

    Here is the vb code for my present.aspx page.




    Class Present



    Inherits System.Web.UI.Page



    Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load



    Dim xN As Byte



    Dim xR As Byte



    Dim xI As Byte



    Dim xA As Byte



    Dim xS As Byte



    Dim xE As Byte



    Dim xC As Byte

    xN = 1



    Me.fNum.Text = xN.ToString

    fR.Text = xR.ToString

    fI.Text = xI.ToString

    fA.Text = xA.ToString

    fS.Text = xS.ToString

    fE.Text = xE.ToString

    fC.Text = xC.ToString



    'Set up frame 1



    'LPic.image =



    'RPic.image =

    LTxt.Text =


    "Go hicking"

    RTxt.Text =


    "Work on a science project"



    End Sub



    Public Sub LTxt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LTxt.Click



    If xN = 1 Then

    xR = xR + 1

    fR.Text = xR.ToString



    'Set up frame 2

    xN = xN + 1

    fNum.Text = xN.ToString



    'LPic.Image =

    LTxt.Text =


    "Make clay pottery"



    'RPic.Image =

    RTxt.Text =


    "Go to a skating party"



    ElseIf xN = 2 Then



    'code continues to test xN




    End If



    End Sub





    Thursday, October 28, 2010 12:58 PM

All replies

  • I am sorry that the code got stretched out. I went back in to try to compress it, but every time I tried, it just got worse.



    Stephen R. Richards
    Thursday, October 28, 2010 4:14 PM