I have a model class I created; a simple POCO class:
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; }
}
Inside a view, I'd like to call and editor for this model:
<div class="contact-form">
@Html.EditorFor(new Map.WebUI.Models.ContactModel())
</div>
But I get the error:
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:
How can I invoke an editor for a random class, considering the view is not strongly typed to this object type?