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. 4 1159
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:O2******** ******@TK2MSFTN GP09.phx.gbl... 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.
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
............... ........
> Dim arrTempList As New ArrayList() oThis.myArrayLi st = 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 "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:
Dim arrTempList As New ArrayList() oThis.myArrayLi st = 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
"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:Od******** ******@TK2MSFTN GP09.phx.gbl...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 ............... .......
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" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message news:uD******** ******@TK2MSFTN GP09.phx.gbl... Dim arrTempList As New ArrayList() oThis.myArrayLi st = 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 "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:
Dim arrTempList As New ArrayList() oThis.myArrayLi st = 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 "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:Od******** ******@TK2MSFTN GP09.phx.gbl...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 ............... .......
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul C-T |
last post by:
Hi,
Am I trying to be too clever here?
I am trying to write a PHP page to enable me to enter values into a form
then write those values to a text file.
I want to use the form & table that displays these fileds and values in
different ways so am creating one page and parsing variables to it.
The problem appears to be in trying to write the values to a text file. The
page displays the field names correctly but when I submit the form...
|
by: Darren Dale |
last post by:
Hello,
def test(data):
i = ? This is the line I have trouble with
if i==1: return data
else: return data
a,b,c,d = test()
|
by: Steve Hall |
last post by:
Folks,
My secnario involves two tables - ObservationRegister, and Person.
ObservationRegister contains most of the "useful" fields, including
the UserID of the person that raised the record, and the UserID of the
person to whom the record was assigned for action. I need to write a
query to return all values in the ObservationRegister record, but
instead of returning the UserIDs, I need to look up the actual name,
by looking up the name...
|
by: cipher |
last post by:
I have some constant values in my web service that my client application will
require. Having to keep server side and client side definitions insync is
tedious. I am trying to do something like this:
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };
However, the resulting wsdl omits the actual flag values:
- <s:simpleType name="Colors">
|
by: Hennie |
last post by:
I apologise if this is a stupid question, but I would appreciated any
help on this subject.
I want to create a view (VIEW_1 in example below) where I take numeric
values from a field in one table (DEPTH_FROM in TABLE_1) and find the
closest matching values from another field in another table (DEPTH_AT
in TABLE_2) - the higher matching value and the lower matching value.
TABLE_1
| |
by: Jon Paal |
last post by:
I have a custom server control which renders some html.
I want to capture some interim values generated by the control as it processes the data.
is there a way to capture and retrieve the interim values generated by the control, so they can be used elsewhere in the display
page ?
|
by: aleksandar.ristovski |
last post by:
Hello all,
I have been thinking about a possible extension to C/C++ syntax.
The current syntax allows declaring a function that returns a value:
int foo();
however, if I were to return more than one value, for example three
int-s, I would have to change my "logic" and pass the references to my
|
by: Gregor =?UTF-8?B?S292YcSN?= |
last post by:
Hi!
With VALUES you can do something like:
SELECT * FROM (VALUES ('A', 1), ('B', 2), ('C', 2)) AS TEMP(LETTER, NUMBER)
which will give you:
LETTER NUMBER
------ ------
A 1
B 2
C 2
|
by: gigonomics |
last post by:
Hi all,
I hope someone can help me out. I need to return the best available seats subject to the constraint that the seats are side by side (or return X consecutive records from a table column where the values are integers). I can do this programmatically (using code and stored procedures), but it's not a neat solution and there are also performance issues.
Returning the best available X number of seats is very straightforward. But I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |