views:

856

answers:

1

I'm writing my first app with ASP.NET MVP (attempting Supervisory Controller) and Unit Testing (better late than never!), and I've run into a bit of a dilemma. I've written 3 User Controls, all tested and Interfaced up, Presenters in tow. Now I have come to a Page which takes these three User Controls and encountered the following problem:

User Control 1 is DateSelector, it's a Calendar control with a couple of other buttons/lists. Nothing real exciting.

User Control 2 is DailyList. Guess what it is. Anyway, you can select/delete etc.. if you select an item from the gridview, it needs to populate User Control 3.

User Control 3 is ItemDetail. Here are the DropDownLists, TextBoxes, etc... some with existing dependencies on others (selecting an option in DropDown one affects the options in DropDown 2).

If I select a new Date from my DateSelector, do I raise the event from the DateSelector Presenter? I have to somehow let the other User Controls know that a new date was selected, so that they can rebind their data, but how? If I use the Page's Presenter to subscribe to the Presenters of the User Control Views, will I not be blatantly breaking the Law of Demeter (exposing the Presenters as Properties through their Views)? Mustn't I use the Page's Presenter as the All-Knowing Controller of the page? Is there something I am missing?

Everything I've read so far says, "MVP is great, even with User Controls", but the use of User Controls is conveniently forgotten about when it comes to examples. It appears to me MVC would more closely match my pattern of thinking on this one, but currently, MVC is not an option. Any help would be great here. Thanks in advance.

+2  A: 

The Page Presenter has to be the one to coordinate the interactions between the controls on the page. Who else would do it? I'd have the page presenter listen in on the event of the DateSelector user control. From the page presenter's perspective, it probably doesn't need to know who raised the event (view or presenter) as it looks at the DateSelector as a fully encapsulated control. The internal workings should be hidden from the page's presenter.

All it knows is that the DateSelector user control raised an event, and now it needs to notify the other controls on the page, either by raising its own event, or by explicitly calling methods on the presenter.

Haacked
Thanks for the clarification. I guess my true issue was where to define the Event for DateSelector. Since i need to access the event from the Page, it'll have to be declared in the View (but can be raised from the Presenter). FYI, your blog posts were a huge help in getting me started. Thanks!
jstephenson