ProfK、
これが私が試したものです(VS 2010、MVC2):
public class ViewDataBase
{
public int ID { get; set; }
public string Name { get; set; }
}
public class CustomerViewData : ViewDataBase
{
public string Address { get; set; }
}
アクションを右クリックし、CustomerViewData を使用して厳密に型指定された詳細ビューを作成しました。以下が生成されます。
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MyApplication.Models.CustomerViewData>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Index</title>
</head>
<body>
<fieldset>
<legend>Fields</legend>
<div class="display-label">Address</div>
<div class="display-field"><%: Model.Address %></div>
<div class="display-label">ID</div>
<div class="display-field"><%: Model.ID %></div>
<div class="display-label">Name</div>
<div class="display-field"><%: Model.Name %></div>
</fieldset>
<p>
<%: Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) %> |
<%: Html.ActionLink("Back to List", "Index") %>
</p>
</body>
</html>