Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - interim values

 
Thread Tools Search this Thread
Old 03-14-2006, 10:29 PM   #1
Default 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.





Jon Paal
  Reply With Quote
Old 03-15-2006, 12:28 PM   #2
Kevin Spencer
 
Posts: n/a
Default 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:...
>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
  Reply With Quote
Old 03-15-2006, 04:56 PM   #3
Jon Paal
 
Posts: n/a
Default 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.myArrayList = 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
.......................




Jon Paal
  Reply With Quote
Old 03-16-2006, 11:53 AM   #4
Kevin Spencer
 
Posts: n/a
Default Re: interim values
> Dim arrTempList As New ArrayList()
> oThis.myArrayList = arrTempList


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 "myArrayList" (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:

> Dim arrTempList As New ArrayList()
> oThis.myArrayList = arrTempList


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
"arrChartList" 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 ("arrTempList" 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.myArrayList = arrTempList

You are invoking the Setter of the Property to assign the value of the field
"arrChartList". 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:...
>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.myArrayList = 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
> ......................
>
>





Kevin Spencer
  Reply With Quote
Old 03-16-2006, 05:00 PM   #5
Jon Paal
 
Posts: n/a
Default 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" <> wrote in message news:...
>> Dim arrTempList As New ArrayList()
>> oThis.myArrayList = arrTempList

>
> 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 "myArrayList" (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:
>
>> Dim arrTempList As New ArrayList()
>> oThis.myArrayList = arrTempList

>
> 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 "arrChartList" 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 ("arrTempList" 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.myArrayList = arrTempList
>
> You are invoking the Setter of the Property to assign the value of the field "arrChartList". 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:...
>>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.myArrayList = 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
>> ......................
>>
>>

>
>





Jon Paal
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cisco QOS MIB values required manjunatht Hardware 1 06-13-2008 02:34 PM
Values set by javascript are not reflected in serverside(.Net) rchimakurty Software 2 11-28-2007 10:07 AM
Checkbox values problem in gridview thanigaimani.thirumalai Software 0 11-09-2007 05:12 AM
Cisco QOS MIB values required manjunatht Software 0 09-11-2007 05:40 PM
How to make the form View save it's field values in Visual Stdio .NET asammoud Software 0 07-17-2007 10:57 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46