我從MVC3 webforms視圖中看到一個奇怪的錯誤,它讓我難堪。Html.EditorFor throws屬性找不到錯誤
設置: 我有兩個接口定義:
public interface IDbObject {
int Id { get; set; }
string Name { get; set; }
}
public interface IAutomobile : IDbObject {
string VIN { get; set; }
}
public class Automobile : IAutomobile {
public int Id { get; set; }
public string Name { get; set; }
public string VIN { get; set; }
}
我的觀點是一個強類型的視圖:System.Web.Mvc.ViewPage<IAutomobile>
和我的控制器
當我嘗試在Name屬性使用EditorFor
<%= Html.EditorFor(a => a.Name) %>
我收到一個異常:System.ArgumentException:屬性IAutomobile.Name無法b e找到了。
但是,如果我註釋掉這個說法,我對VIN EditorFor繼續正常運行:
<%= Html.EditorFor(a => a.VIN) %>
有我丟失的東西?
我有一種感覺,這可能會導致在使用對象作爲IDbObject時出現問題。 – 2011-03-05 15:51:11
你可能是對的......我會讓你知道;) – 2011-03-05 15:54:20