您现在的位置是:首页 >

aspnet网站开发实例 ASP.NET MVC 4框架揭秘:MVP(1)[2]

火烧 2021-11-30 20:06:48 1040
ASP.NET MVC 4框架揭秘:MVP(1)[2]   正确的接口和实现该接口的View(一个We 页面)应该采用如下的定义方式 Pre e ter通过对属性De artme t 和Em loye

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

  正确的接口和实现该接口的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

  {

  this DropDownListDepartments DataSource = value;

  this DropDownListDepartments DataBind()

  }

  }

  public string SelectedDepartment

  {

  get { return this DropDownListDepartments SelectedValue;}

  }

  public IEnumerable<Employee> Employees

aspnet网站开发实例 ASP.NET MVC 4框架揭秘:MVP(1)[2]

  {

  set

  {

  this GridViewEmployees DataSource = value;

  this GridViewEmployees DataBind()

  }

  }

  }

      返回目录ASP NET MVC 框架揭秘

      编辑推荐

       Java程序性能优化 让你的Java程序更快 更稳定

       Visual C++音频/视频技术开发与实战

lishixinzhi/Article/program/net/201311/16128  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码