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

G

Guest

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(sYear).cMonths(sMonth).cDays(sDay).cEvents(sID).EventText

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


Public Class EventsCal
Inherits System.Web.UI.Page


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
---------------------------

<SCRIPT language="vbscript" id="clientEventHandlersVBS">
<!--

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: 'ELFsearchClient"

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!!!
 
H

Hans Kesting

kermit said:
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(sYear).cMonths(sMonth).cDays(sDay).cEvents(sID).EventText

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



Public Class EventsCal
Inherits System.Web.UI.Page


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
---------------------------


<SCRIPT language="vbscript" id="clientEventHandlersVBS">
<!--

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: 'ELFsearchClient"

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
 
G

Guest

Hans Kesting said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top