MVP design pattern question

Posted on 2007-10-08
Last Modified: 2012-05-05
Hi experts,

I have events that get fired from my View and get handled in my Presenter
for example i might have in my View:
            this.radioButtonList.SelectedIndexChanged += delegate
                OnClassSelected(this.radioButton, EventArgs.Empty);
and OnClassSelected gets handled in my presenter:
void _view_OnClassSelected(object sender, EventArgs)

My problem is how can i use the sender parameter to for example get the selected value if I don't have access to System.Web.UI.WebControls to cast the sender object to a RadioButtonList?

Question by:kateL
    LVL 14

    Expert Comment

    just cast it

    Author Comment

    what if my presenter is in a different project which does not have a reference to System.Web. That is the problem I mean.

    What is the best practice in this case when using the MVP?

    one solution would be to expose the SelectValue property though the interface but is this the best way?

    I can see that it would get very cumbersome doing this if you had loads of controls to deal with
    LVL 29

    Accepted Solution

    this.radioButtonList.SelectedIndexChanged += delegate
                    OnClassSelected(this.radioButton.SelectedValue, EventArgs.Empty);
    LVL 14

    Expert Comment

    no its not the best way to expose the selectedValue alone...

    check this - may be you will get some idea...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now