Timing

Discussion in 'ASP .Net' started by m_j_mather@yahoo.com.au, Jan 26, 2005.

  1. Guest

    Hi everyone,

    I'm neck deep in ASP.NET and sinking fast ;) Any help much
    appreciated.

    I have two user controls on a page that I want to communicate with each
    other. One control is called RoleList and allows the user to select
    the type of view they wish to see on the page. The other control(s) -
    sometimes there may be several - then change the stored proc, query etc
    they use to extract info from sql.

    Therefore, I have set up the RoleList to generate an event and coded
    the other control(s) to listen and recieve it.

    The problem is timing. I've done some tracing to see what happens and
    when:

    1 aspx.page Begin Init
    2 aspx.page End Init
    3 aspx.page Begin LoadViewState
    4 aspx.page End LoadViewState
    5 aspx.page Begin ProcessPostData
    6 aspx.page End ProcessPostData
    7 Control ID: RoleList - role was previously set in the viewstate:
    tutor
    8 Control ID: StudentList - role was previously set in the viewstate:
    tutor
    9 aspx.page Begin ProcessPostData Second Try
    10 aspx.page End ProcessPostData Second Try
    11 aspx.page Begin Raise ChangedEvents
    12 aspx.page End Raise ChangedEvents
    13 aspx.page Begin Raise PostBackEvent
    14 Changing role to: Secretary
    15 Control ID: RoleList - changed role to: Secretary
    16 Control ID: StudentList - changed role to: Secretary
    17 aspx.page End Raise PostBackEvent
    18 aspx.page Begin PreRender
    19 aspx.page End PreRender
    20 aspx.page Begin SaveViewState
    21 aspx.page End SaveViewState
    22 aspx.page Begin Render
    23 aspx.page End Render


    Line 7 and 8 came from the page_load event in each control.

    Line 14 came from the event being fired and the next two is where the
    event is caught.

    But the Load event (which contains the data binding for the list /
    grids etc) for the response has already happened! Therefore the user
    must click the role they want to see TWICE!!!

    I could probably make some public properties in the base page and
    read/write info from them to get around this. But this will mess up my
    otherwise quite low coupling and I don't want to.

    Thanks in adv.

    Mark.
     
    , Jan 26, 2005
    #1
    1. Advertising

  2. wrote in
    news::

    >
    > Hi everyone,
    >
    > I'm neck deep in ASP.NET and sinking fast ;) Any help much
    > appreciated.
    >
    > I have two user controls on a page that I want to communicate
    > with each other. One control is called RoleList and allows the
    > user to select the type of view they wish to see on the page.
    > The other control(s) - sometimes there may be several - then
    > change the stored proc, query etc they use to extract info from
    > sql.
    >
    > Therefore, I have set up the RoleList to generate an event and
    > coded the other control(s) to listen and recieve it.
    >
    > The problem is timing. I've done some tracing to see what
    > happens and when:
    >
    > 1 aspx.page Begin Init
    > 2 aspx.page End Init
    > 3 aspx.page Begin LoadViewState
    > 4 aspx.page End LoadViewState
    > 5 aspx.page Begin ProcessPostData
    > 6 aspx.page End ProcessPostData
    > 7 Control ID: RoleList - role was previously set in the
    > viewstate: tutor
    > 8 Control ID: StudentList - role was previously set in the
    > viewstate: tutor
    > 9 aspx.page Begin ProcessPostData Second Try
    > 10 aspx.page End ProcessPostData Second Try
    > 11 aspx.page Begin Raise ChangedEvents
    > 12 aspx.page End Raise ChangedEvents
    > 13 aspx.page Begin Raise PostBackEvent
    > 14 Changing role to: Secretary
    > 15 Control ID: RoleList - changed role to: Secretary
    > 16 Control ID: StudentList - changed role to: Secretary
    > 17 aspx.page End Raise PostBackEvent
    > 18 aspx.page Begin PreRender
    > 19 aspx.page End PreRender
    > 20 aspx.page Begin SaveViewState
    > 21 aspx.page End SaveViewState
    > 22 aspx.page Begin Render
    > 23 aspx.page End Render
    >
    >
    > Line 7 and 8 came from the page_load event in each control.
    >
    > Line 14 came from the event being fired and the next two is
    > where the event is caught.
    >
    > But the Load event (which contains the data binding for the list
    > / grids etc) for the response has already happened! Therefore
    > the user must click the role they want to see TWICE!!!
    >
    > I could probably make some public properties in the base page
    > and read/write info from them to get around this. But this will
    > mess up my otherwise quite low coupling and I don't want to.


    Mark,

    It looks like you need to conditionally perform the databinding in
    two places: the page (or control) load event, and the RoleList
    Changed event.

    In the page/control Load event, only perform the databinding if the
    page has not been posted back. If the page has been posted back,
    another event handler is going to be responsible for the databinding
    (RoleList Changed, in this case).

    In the RoleList Changed event, iterate through all of the controls on
    the page, and send a message to all of the StudentList controls.

    foreach (Control ctrl in this.Controls)
    {
    if (ctrl is StudentList)
    (ctrl as StudentList).SendAMessage("new role value goes here");
    }

    --
    Hope this helps.

    Chris.
    -------------
    C.R. Timmons Consulting, Inc.
    http://www.crtimmonsinc.com/
     
    Chris R. Timmons, Jan 26, 2005
    #2
    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. Kieran Francisco

    Timing Diagram to HDL Translation

    Kieran Francisco, Sep 8, 2003, in forum: VHDL
    Replies:
    9
    Views:
    1,294
    VhdlCohen
    Sep 17, 2003
  2. Kload

    Strange Timing Problem

    Kload, Oct 23, 2003, in forum: VHDL
    Replies:
    2
    Views:
    594
    Kload
    Oct 23, 2003
  3. Kload
    Replies:
    1
    Views:
    555
    John_H
    Oct 23, 2003
  4. ramzi
    Replies:
    0
    Views:
    521
    ramzi
    Nov 1, 2003
  5. guille
    Replies:
    0
    Views:
    575
    guille
    Dec 19, 2003
Loading...

Share This Page