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

Discussion in 'ASP .Net' started by =?Utf-8?B?a2VybWl0?=, Apr 26, 2005.

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

    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!!!
     
    =?Utf-8?B?a2VybWl0?=, Apr 26, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?a2VybWl0?=

    Hans Kesting Guest

    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).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.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 Kesting, Apr 26, 2005
    #2
    1. Advertising

  3. "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).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.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.
    >
     
    =?Utf-8?B?a2VybWl0?=, Apr 26, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sriram Mallajyosula

    How do I post data from aspx page to another aspx page.

    Sriram Mallajyosula, Nov 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,001
    Steve C. Orr [MVP, MCSD]
    Nov 5, 2003
  2. Marco Antonio Montalvo Durán
    Replies:
    2
    Views:
    4,156
    Matt Morris
    Jan 23, 2004
  3. John M
    Replies:
    1
    Views:
    1,213
    Kumar Reddi
    May 29, 2005
  4. =?Utf-8?B?Uk1M?=
    Replies:
    1
    Views:
    575
    =?Utf-8?B?QW5keSBMdWtzaWM=?=
    Sep 16, 2005
  5. Øyvind Isaksen
    Replies:
    1
    Views:
    987
    Øyvind Isaksen
    May 18, 2007
Loading...

Share This Page