开发者

ASP.NET Web Forms - Model View Presenter and user controls

I'm new to using the MVP pattern and I just want to make sure on the best way to call a presenter from within a user control.

MyPage.aspx has a presenter MyPresenter

The page contains a user control which accepts MyPage's Presenter via a property which I setup from MyPage

MyUserControl.Presenter = this.Presenter

I'm now trying to call Method1 within the presenter which retrieves some config and sets it on the view from the user control.

Presenter.Method1(); // calls method and sets config to the view

My question is firstly

  1. should I be using the presenter in the user control in this way?
  2. If so, i开发者_如何转开发s it valid to be accessing the view value via the user control as shown below.

    Presenter.View.MyData

I just want to make sure I'm not going off down the completely wrong path with this!


What I use to do is to have one presenter for each user control which is responsible only for the user control presentation and one presenter for each page (.aspx). I think keeping things separated helps also for maintaining as you will have "skinny" presenter which are responsible only of a small section of the UI. The user control will be also "self-contained" in the way that you can reuse them as the presentation logic is kept separated from the page presentation logic.

have a look at the following post:

MVP and UserControls and invocation

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜