0
我剛開始在我正在構建的大型ASP.NET應用程序中使用MVP模式(實際上正在重新構建),而且我很難搞清楚如何我應該使用應用於視圖的事件。使用MVP - 如何正確使用事件來測試
說我有2下拉列表中的用戶控件,其中一個是依賴於其他的價值:
<%@ 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" />
應該如何將AutoPostBack事件在接口中定義?應該是這樣的用戶控件處理的事件:
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
或者應該在界面上定義一個事件嗎?如果這是首選模式,我如何添加要處理和使用的事件?