473,587 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to return a collection from a class to a aspx page

I have a .net aspx page MyPage.aspx (client side) with code behind
MyPage.aspx.vb (server side).

I use the Page_Load event in MyPage.aspx.vb to load data into a multiteir
class based collection.

MyCollection(sY ear).cMonths(sM onth).cDays(sDa y).cEvents(sID) .EventText

My problem arrives when I try to access this collection from the page
(MyPage.aspx).

On the page's server side I have:
MyPage.aspx.vb <<<
Public Class EventsCal
Inherits System.Web.UI.P age
Private moColYears As colYears

Private Sub Page_Load(....
(Code to load data into class...)

end sub

Public Function AbvCollection() As colYears
Return moColYears
End Function

Public Function AbvTest() As Integer
Return 1
End Function
---------------------------
On the page's client side I have: MyPage.aspx <<<


<SCRIPT language="vbscr ipt" id="clientEvent HandlersVBS">
<!--

Private oColYears

Sub window_onload
set oColYears = <%= AbvCollection() %>
...
---------------------------
---------------------------
colYears is initial level of my class collection structure
colYears.vb
oYear.vb
colMonths.vb
oMonths.vb
etc.

If I set set oColYears = <%= AbvTest() %> it works just fine.
However, when I
set oColYears = <%= AbvCollection() %>

I receive an error of

....runtime error: Object required: 'ELFsearchClien t"

ELFsearchClient is the app name.

I have tried this sixteen different ways. There must be a way to access
the class collection data.

What am I doing wrong??????

Thank you for all help!!!
Nov 19 '05 #1
2 1632
kermit wrote:
I have a .net aspx page MyPage.aspx (client side) with code behind
MyPage.aspx.vb (server side).

I use the Page_Load event in MyPage.aspx.vb to load data into a
multiteir class based collection.

MyCollection(sY ear).cMonths(sM onth).cDays(sDa y).cEvents(sID) .EventText

My problem arrives when I try to access this collection from the
page (MyPage.aspx).

On the page's server side I have:
MyPage.aspx.vb <<<
Public Class EventsCal
Inherits System.Web.UI.P age
Private moColYears As colYears

Private Sub Page_Load(....
(Code to load data into class...)

end sub

Public Function AbvCollection() As colYears
Return moColYears
End Function

Public Function AbvTest() As Integer
Return 1
End Function
---------------------------
On the page's client side I have: MyPage.aspx <<<


<SCRIPT language="vbscr ipt" id="clientEvent HandlersVBS">
<!--

Private oColYears

Sub window_onload
set oColYears = <%= AbvCollection() %>
...
---------------------------
---------------------------
colYears is initial level of my class collection structure
colYears.vb
oYear.vb
colMonths.vb
oMonths.vb
etc.

If I set set oColYears = <%= AbvTest() %> it works just fine.
However, when I
set oColYears = <%= AbvCollection() %>

I receive an error of

...runtime error: Object required: 'ELFsearchClien t"

ELFsearchClient is the app name.

I have tried this sixteen different ways. There must be a way to
access the class collection data.

What am I doing wrong??????

Thank you for all help!!!


You are trying to generate client-side vbscript. When you use AbvCollection()
in this way, some string representation is used. I don't think that vbscript
will understand that.
Take a look at the generated vbscript (view source in the browser). I think
you will see something like
set oColYears = <the classname of the collection>
You will need to find a way to translate the contents of the collection into
something that client-side vbscript can work with. (sorry, I can't help you
with that)

Remember: client-side code and server-side code do *not* run at the same
time! First the server-side code runs, this generates a text file (containing html
and script) which gets interpreted by the browser, that in turn will run
any client side code there.

Hans Kesting
Nov 19 '05 #2


"Hans Kesting" wrote:
kermit wrote:
I have a .net aspx page MyPage.aspx (client side) with code behind
MyPage.aspx.vb (server side).

I use the Page_Load event in MyPage.aspx.vb to load data into a
multiteir class based collection.

MyCollection(sY ear).cMonths(sM onth).cDays(sDa y).cEvents(sID) .EventText

My problem arrives when I try to access this collection from the
page (MyPage.aspx).

On the page's server side I have:
> MyPage.aspx.vb <<<
Public Class EventsCal
Inherits System.Web.UI.P age
Private moColYears As colYears

Private Sub Page_Load(....
(Code to load data into class...)

end sub

Public Function AbvCollection() As colYears
Return moColYears
End Function

Public Function AbvTest() As Integer
Return 1
End Function
---------------------------
On the page's client side I have:
> MyPage.aspx <<<


<SCRIPT language="vbscr ipt" id="clientEvent HandlersVBS">
<!--

Private oColYears

Sub window_onload
set oColYears = <%= AbvCollection() %>
...
---------------------------
---------------------------
colYears is initial level of my class collection structure
colYears.vb
oYear.vb
colMonths.vb
oMonths.vb
etc.

If I set set oColYears = <%= AbvTest() %> it works just fine.
However, when I
set oColYears = <%= AbvCollection() %>

I receive an error of

...runtime error: Object required: 'ELFsearchClien t"

ELFsearchClient is the app name.

I have tried this sixteen different ways. There must be a way to
access the class collection data.

What am I doing wrong??????

Thank you for all help!!!


You are trying to generate client-side vbscript. When you use AbvCollection()
in this way, some string representation is used. I don't think that vbscript
will understand that.
Take a look at the generated vbscript (view source in the browser). I think
you will see something like
set oColYears = <the classname of the collection>
You will need to find a way to translate the contents of the collection into
something that client-side vbscript can work with. (sorry, I can't help you
with that)

Remember: client-side code and server-side code do *not* run at the same
time! First the server-side code runs, this generates a text file (containing html
and script) which gets interpreted by the browser, that in turn will run
any client side code there.

Hans Kesting

Hans,
You are correct it translates it into: ELFsearchClient .colYears
which is my applications name . collections class name. I keep
getting tangled up in trying to pass data from the server side to the
client side. I thought using a class would maybe allow me to do that.
But I guess if I think about it, the class is entirely server side. I
really want an indexed collection type on the client side. But have
not come up with anything that works yet. As the user takes certain
actions I want to reload certain controls with new data based on selections
and did not want to have to get a new dataset each time. These are
client side only controls, can't set them to runon server.

Thank you for your observations.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
6906
by: Kathy Burke | last post by:
HI. in asp.net app, I have an xmlDocument that I transform to the client html. Using xsl I create a few textboxes to capture user input. Each of these are related to <data> elements in the xmlDoc. I want to use the Forms collection to post the html form back to an asp.net page, and process each request.form object (textbox) via an xml...
1
1405
by: Jeff S | last post by:
I'm storing a list of widgets in a database. The list changes infrequently (twice per week at most), and is relatively short (200 items at most, with very little detail per item). A small subset of all possible widgets will be displayed on a page (using VB.NET/code behind). I plan to populate a custom collection/class with a list of all...
3
1285
by: TJS | last post by:
from a code class, a] how does one dimension a collection and then b] after it is created, reassign it in the page ? I'm getting only errors on line of code in the page. "System.NullReferenceException: Object variable or With block variable not set "
6
1854
by: Whoever | last post by:
Here's what I have A custom collection: public class aUser { public string UserName { get {...} set {...} } public class UserList : System.Collection.CollectionBase { public void Add(aUser user) {...} public aUser this {...}
2
1301
by: kermit | last post by:
I have an .net aspx page MyPage.aspx (client side), with code behind MyPage.aspx.vb (server side) I use the pages server On_Load event (.aspx.vb) to create a collection using classes. Public Class CollectionPage Inherits Web.UI.Page
7
1797
by: nafri | last post by:
hello all, I want to create a function that returns the first element of the Array that is input to it. However, the Input Array can be an Array of points, double, or anyother type, which means the return type of the function depends on the type of the objects the Input array holds. I can have the return type as Object, but it has problems...
1
4407
by: Thomas D. | last post by:
Hello all, I'm using the IXmlSerializable interface for a project and encounter some problems when testing my webservice in a client application. I know this interface is undocumented and not intended for use, but I think this is the only solution for my situation. I searched the web, in the hope finding the answer, without any luck, so my...
6
1784
by: Joe | last post by:
Hello All: I have a webform (WebForm1.aspx) that retrieves a value from a database (_formSessionId) the first time that it is posted. After the user filles in the form, he/she clicks a Button server control that ultimately redirects him/her to WebForm2.aspx . I need to persist the value of _formSessionId between the initial post and the...
4
1751
by: Robert Schneider | last post by:
Hi, the msdn documentation provides an Dinosaurs example that uses the objectmodel.collection class. Just have a look on the help page for this class. I don't understand what happens here. Or I cannot find more detailed documentation for this behavior. What I mean is the invocation of the Dinosaurs.Add method which is derived from...
0
7915
marktang
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...
0
8205
Oralloy
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. ...
0
8339
jinu1996
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...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
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...
1
5712
isladogs
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...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.