locked
Web forms and events RRS feed

  • Question

  • User-340570214 posted

     A design issue regarding web forms user interfaces has been bugging me for some time. It is an "order of events" issue, which good design should eliminate right.. but how?

     Lets say I have written a User Control which takes some input from the user. In order to encapsulate the User Control, I've created an event which the control fires when (if) the user has made some sort of change. The event tells other parties (ie. the parent page) both the fact that the user has done something, and event data tells us what they did.

    Now, I drop the User Control onto a page. The page also has a button that causes postback. What happens next depends on whether the user did something to the User Control - ie. we need the User Control's event to fire before the button's OnClick event. My experience has been that the order of events is usually User Control, then Button, but not always, and there is no guarantee.

    I know I could expose the User Control's input as a public property, and access it in the Button click event handler, but it just doesn't feel right - it wreaks of tight coupling.

    Thanks 

    Monday, June 16, 2008 5:04 PM

Answers

  • User-16411453 posted

     Make 2 controls. 

    One control updates the other control.  Haven't done it yet, but I have a need for it later in the week. 

    Should not be a problem, because I have made controls earlier, in which somehow by mistake, one control was changing another controls values by accident upon postback events.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 17, 2008 6:40 PM

All replies

  • User-16411453 posted

     Someone else had the exact same question in aother post here in this forum

    I would make 1 giant user control, that contains all the buttons and events, or 2 controls that talk to each other. 

    Tuesday, June 17, 2008 4:42 PM
  • User-340570214 posted

     The giant user control approach doesn't help as I want to re-use my User Control elsewhere. Making a giant means adding in other controls that end up making the User Control single-use only, so there goes re-useability.

     Can you elaborate on the 2 controls taking to each other? Do you mean talking via events?

    Thanks for your response.
     

    Tuesday, June 17, 2008 5:06 PM
  • User-16411453 posted

     Make 2 controls.  One control updates the other control.  Haven't done it yet, but I have a need for it later in the week.  Should not be a problem, because I have made controls earlier, in which somehow by mistake, one control was changing another controls values by accident upon postback events.

     

    Tuesday, June 17, 2008 6:38 PM
  • User-16411453 posted

     Make 2 controls. 

    One control updates the other control.  Haven't done it yet, but I have a need for it later in the week. 

    Should not be a problem, because I have made controls earlier, in which somehow by mistake, one control was changing another controls values by accident upon postback events.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 17, 2008 6:40 PM