Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to return a collection from a class to a aspx page

Reply
Thread Tools

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

 
 
=?Utf-8?B?a2VybWl0?=
Guest
Posts: n/a
 
      04-26-2005
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).cE vents(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.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
---------------------------
On the page's client side I have:
>>> MyPage.aspx <<<


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


 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      04-26-2005
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(sYear).cMonths(sMonth).cDays(sDay).cE vents(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.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
> ---------------------------
> On the page's client side I have:
>>>> MyPage.aspx <<<

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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?a2VybWl0?=
Guest
Posts: n/a
 
      04-26-2005


"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(sYear).cMonths(sMonth).cDays(sDay).cE vents(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.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
> > ---------------------------
> > On the page's client side I have:
> >>>> MyPage.aspx <<<

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

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
Loading an aspx page in a fram from another aspx page =?Utf-8?B?Uk1M?= ASP .Net 1 09-16-2005 01:21 PM
adding main.aspx.vb & main.aspx.resx under aspx John M ASP .Net 1 05-29-2005 09:27 PM
How to Pass values between from a popup page aspx & a normal page aspx Marco Antonio Montalvo Durán ASP .Net 2 01-23-2004 09:35 PM
How do I post data from aspx page to another aspx page. Sriram Mallajyosula ASP .Net 1 11-05-2003 04:48 PM



Advertisments