Asp.net 使用MVP-如何正确使用事件进行测试
我刚刚开始在我正在构建的大型ASP.NET应用程序中使用MVP模式(实际上是重新构建),我很难弄清楚应该如何使用应用于视图的事件 假设在用户控件中有两个下拉列表,其中一个取决于另一个的值:Asp.net 使用MVP-如何正确使用事件进行测试,asp.net,design-patterns,mvp,Asp.net,Design Patterns,Mvp,我刚刚开始在我正在构建的大型ASP.NET应用程序中使用MVP模式(实际上是重新构建),我很难弄清楚应该如何使用应用于视图的事件 假设在用户控件中有两个下拉列表,其中一个取决于另一个的值: <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucTestMVP.ascx.vb" Inherits=".ucTestMVP" %> <asp:DropDownList ID="ddlCountry" ru
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucTestMVP.ascx.vb" Inherits=".ucTestMVP" %>
<asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True" />
<asp:DropDownList ID="ddlCity" runat="server" />
或者应该在接口上定义一个事件?如果这是首选模式,如何添加要处理和使用的事件?我不知道是否有普遍首选的模式。我倾向于将事件添加到视图界面,并让演示者响应视图。我在一篇文章中描述了这种模式
Public Partial Class ucTestMVP
Inherits System.Web.UI.UserControl
Implements ITestMVPView
Protected Sub PageLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim presenter As New TestMVPPresenter(Me)
presenter.InitView()
End If
End Sub
Private Sub ddlCountrySelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCountry.SelectedIndexChanged
Dim presenter as New TestMVPPresenter(Me)
presenter.CountryDDLIndexChanged()
End Sub
End Class