熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.NET MVC 4框架揭秘:MVP(1)[2]

2013-11-13 12:32:52  來源: .NET編程 

  正確的接口和實現該接口的View(一個Web頁面)應該采用如下的定義方式Presenter通過對屬性Departments和Employees賦值進而實現對相應DropDownList和GridView的數據綁定通過屬性SelectedDepartment得到用戶選擇的篩選部門為了盡可能讓接口只暴露必需的信息我們特意將對屬性的讀/寫作了控制

  public interface IEmployeeSearchView

  {

  IEnumerable<string>       Departments { set; }

  string                    SelectedDepartment { get; }

  IEnumerable<Employee>         Employees { set; }

  }

  public partial class EmployeeSearchView: Page IEmployeeSearchView

  {

  //其他成員

  public IEnumerable<string> Departments

  {

  set

  {

  thisDropDownListDepartmentsDataSource = value;

  thisDropDownListDepartmentsDataBind()

  }

  }

  public string SelectedDepartment

  {

  get { return thisDropDownListDepartmentsSelectedValue;}

  }

  public IEnumerable<Employee> Employees

  {

  set

  {

  thisGridViewEmployeesDataSource = value;

  thisGridViewEmployeesDataBind()

  }

  }

  }

       返回目錄ASPNET MVC 框架揭秘

       編輯推薦

       Java程序性能優化讓你的Java程序更快更穩定

       Visual C++音頻/視頻技術開發與實戰

[]  []  


From:http://tw.wingwit.com/Article/program/net/201311/16128.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.