我有我創建的模型類;一個簡單的POCO類:CS0411:方法'System.Web.Mvc.Html.EditorExtensions.EditorFor <>的類型參數''不能從使用推斷
public class ContactModel
{
[Required]
public string Name { get; set; }
[Required]
public string Email { get; set; }
[Required]
public string Message { get; set; }
[Required]
public string Work{ get; set; }
}
裏面一個觀點,我想打電話和編輯這個模型:
<div class="contact-form">
@Html.EditorFor(new Map.WebUI.Models.ContactModel())
</div>
但我得到的錯誤:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0411: The type arguments for method 'System.Web.Mvc.Html.EditorExtensions.EditorFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Source Error:
哪有我爲隨機類調用編輯器,考慮視圖是而不是強類型爲此對象類型?
我明確**不要**要將視圖設置爲強類型爲此對象類型。 – sergserg