interim values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon   Paal

    interim values

    I am using a custom server control in my webpage which renders some html.

    while it creates the html, it develops an arraylist of values. Is there a way to capture the arraylist from the control so it can
    also be used on the same web page ?

    this needs to happen in the post back.



  • Kevin Spencer

    #2
    Re: interim values

    If the array of values is a public property of the class, the Page can
    access it.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer

    Presuming that God is "only an idea" -
    Ideas exist.
    Therefore, God exists.

    "Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message
    news:O2WzOb7RGH A.1160@TK2MSFTN GP09.phx.gbl...[color=blue]
    >I am using a custom server control in my webpage which renders some html.
    >
    > while it creates the html, it develops an arraylist of values. Is there a
    > way to capture the arraylist from the control so it can also be used on
    > the same web page ?
    >
    > this needs to happen in the post back.
    >
    >
    >[/color]


    Comment

    • Jon   Paal

      #3
      Re: interim values

      I have the arraylist defined as a public property and I can verify that the list has values when the server control is running, but
      when I try to use the arraylist in my webpage, it is empty .

      What am I doing wrong with the properties ?

      I create the property wth the webpage by:

      ............... .
      Dim arrTempList As New ArrayList()
      oThis.myArrayLi st = arrTempList
      ...............


      I have the the property defined in the control as:

      ............... ......
      Public arrChartList As Arraylist
      Public Property myArrayList As ArrayList
      Get
      Return arrChartList
      End Get
      Set
      arrChartList = value
      End Set
      End Property
      ............... ........


      Comment

      • Kevin Spencer

        #4
        Re: interim values

        > Dim arrTempList As New ArrayList()[color=blue]
        > oThis.myArrayLi st = arrTempList[/color]

        You seem to be initializing an ArrayList somewhere in the code of your
        Control. When you initialize it, it is empty. You then assing it to a public
        property "myArrayLis t" (not sure where the "o" came from, but if the code
        compiles, I'm assuming it's not in your actual code). The public property
        exposes a private ("arrChartList" ) ArrayList. Kludgy, but it will work. So
        far.

        Now, what you have told me is that when you "try to use the arraylist" in
        your "webpage" it is empty. Why that is, I can't tell from what you've
        posted, as nothing you've posted indicates how it is supposed to be
        populated, at what point in the execution cycle it is populated, if and how
        it is persisted across PostBacks, etc.

        At this point, all I can give you is a pointer or 2 on your initialization
        of the ArrayList:
        [color=blue]
        > Dim arrTempList As New ArrayList()
        > oThis.myArrayLi st = arrTempList[/color]

        This is all completely unnecessary. Consider the following:

        Protected arrChartList As New Arraylist()
        Public Property myArrayList As ArrayList
        Get
        Return arrChartList
        End Get
        Set
        arrChartList = value
        End Set
        End Property

        or, if you want to be even more simple, since you declared the
        "arrChartLi st" as Public:

        Public arrChartList As New Arraylist()

        Why? Well, first, a field and a variable are the same thing in different
        scopes. When you say:

        Dim arrTempList As New ArrayList()

        at class scope, you are saying the same thing as:

        Private arrTempList As New ArrayList()

        So, in essence, you've declared 2 fields ("arrTempLis t" and "arrChartList") ,
        and simply assigned the value of one to the other. Now you have 2 fields
        that point to the same ArrayList.

        Second, when you assign it to the Public Property:

        This.myArrayLis t = arrTempList

        You are invoking the Setter of the Property to assign the value of the field
        "arrChartLi st". In other words, you are using indirection, and calling a
        method to assign a value which could be assigned less expensively by simple
        assignment. But again, it is not necessary to declare 2 fields.

        --
        HTH,

        Kevin Spencer
        Microsoft MVP
        ..Net Developer

        Presuming that God is "only an idea" -
        Ideas exist.
        Therefore, God exists.

        "Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message
        news:OdrVfFFSGH A.3192@TK2MSFTN GP09.phx.gbl...[color=blue]
        >I have the arraylist defined as a public property and I can verify that the
        >list has values when the server control is running, but when I try to use
        >the arraylist in my webpage, it is empty .
        >
        > What am I doing wrong with the properties ?
        >
        > I create the property wth the webpage by:
        >
        > ...............
        > Dim arrTempList As New ArrayList()
        > oThis.myArrayLi st = arrTempList
        > ..............
        >
        >
        > I have the the property defined in the control as:
        >
        > ............... .....
        > Public arrChartList As Arraylist
        > Public Property myArrayList As ArrayList
        > Get
        > Return arrChartList
        > End Get
        > Set
        > arrChartList = value
        > End Set
        > End Property
        > ............... .......
        >
        >[/color]


        Comment

        • Jon   Paal

          #5
          Re: interim values

          All of this activity happens in the postback.
          I'm using vb.net so "oThis" is simply an instance of the control.

          I know the coding is sloppy, but I'm groping around trying to get this to work.

          The property ideally should be populated from a function in the control. The function requires use of all other properties.

          I can sort of get the arraylist if I assign it to a session value inside the control and then display the session value from the web
          page. Unfortunately, it's always displaying the "previous" value ( last set of user choices) unless I refresh the page, then I get
          the current value.

          I can't understand why it's impossible to get the interim value back from the property during the postback. I even tried creating a
          separate instance of the object and although I can confirm it is running correctly I still can't get back a value from the property.
          ?????


          Is this a problem because the control has been designed to override the render for outputting the html ??




          "Kevin Spencer" <kevin@DIESPAMM ERSDIEtakempis. com> wrote in message news:uDFgvAPSGH A.4952@TK2MSFTN GP09.phx.gbl...[color=blue][color=green]
          >> Dim arrTempList As New ArrayList()
          >> oThis.myArrayLi st = arrTempList[/color]
          >
          > You seem to be initializing an ArrayList somewhere in the code of your Control. When you initialize it, it is empty. You then
          > assing it to a public property "myArrayLis t" (not sure where the "o" came from, but if the code compiles, I'm assuming it's not in
          > your actual code). The public property exposes a private ("arrChartList" ) ArrayList. Kludgy, but it will work. So far.
          >
          > Now, what you have told me is that when you "try to use the arraylist" in your "webpage" it is empty. Why that is, I can't tell
          > from what you've posted, as nothing you've posted indicates how it is supposed to be populated, at what point in the execution
          > cycle it is populated, if and how it is persisted across PostBacks, etc.
          >
          > At this point, all I can give you is a pointer or 2 on your initialization of the ArrayList:
          >[color=green]
          >> Dim arrTempList As New ArrayList()
          >> oThis.myArrayLi st = arrTempList[/color]
          >
          > This is all completely unnecessary. Consider the following:
          >
          > Protected arrChartList As New Arraylist()
          > Public Property myArrayList As ArrayList
          > Get
          > Return arrChartList
          > End Get
          > Set
          > arrChartList = value
          > End Set
          > End Property
          >
          > or, if you want to be even more simple, since you declared the "arrChartLi st" as Public:
          >
          > Public arrChartList As New Arraylist()
          >
          > Why? Well, first, a field and a variable are the same thing in different scopes. When you say:
          >
          > Dim arrTempList As New ArrayList()
          >
          > at class scope, you are saying the same thing as:
          >
          > Private arrTempList As New ArrayList()
          >
          > So, in essence, you've declared 2 fields ("arrTempLis t" and "arrChartList") , and simply assigned the value of one to the other.
          > Now you have 2 fields that point to the same ArrayList.
          >
          > Second, when you assign it to the Public Property:
          >
          > This.myArrayLis t = arrTempList
          >
          > You are invoking the Setter of the Property to assign the value of the field "arrChartLi st". In other words, you are using
          > indirection, and calling a method to assign a value which could be assigned less expensively by simple assignment. But again, it
          > is not necessary to declare 2 fields.
          >
          > --
          > HTH,
          >
          > Kevin Spencer
          > Microsoft MVP
          > .Net Developer
          >
          > Presuming that God is "only an idea" -
          > Ideas exist.
          > Therefore, God exists.
          >
          > "Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message news:OdrVfFFSGH A.3192@TK2MSFTN GP09.phx.gbl...[color=green]
          >>I have the arraylist defined as a public property and I can verify that the list has values when the server control is running,
          >>but when I try to use the arraylist in my webpage, it is empty .
          >>
          >> What am I doing wrong with the properties ?
          >>
          >> I create the property wth the webpage by:
          >>
          >> ...............
          >> Dim arrTempList As New ArrayList()
          >> oThis.myArrayLi st = arrTempList
          >> ..............
          >>
          >>
          >> I have the the property defined in the control as:
          >>
          >> ............... .....
          >> Public arrChartList As Arraylist
          >> Public Property myArrayList As ArrayList
          >> Get
          >> Return arrChartList
          >> End Get
          >> Set
          >> arrChartList = value
          >> End Set
          >> End Property
          >> ............... .......
          >>
          >>[/color]
          >
          >[/color]


          Comment

          Working...