Search code examples
asp.net-mvcasp.net-mvc-4razorasp.net-mvc-5mvc-editor-templates

Defining a View inisde the shared/EditorTemplete folder is not working on my asp.net mvc-4 web application


I am working on an asp.net mvc-4 web application. now i have the following view model class:-

public class ServerJoin : CreateResource,  IValidatableObject
{
    public Server Server { get; set; }
    public Resource Resource { get; set; }
}

and the CreateResource class is as follow:-

 public class CreateResource
    {
        public CreateResource()
        {
            this.operation = new Operation5();
            this.createAccount = new CreateAccount();
        }
        public Operation5 operation { get; set; }
        public CreateAccount createAccount { get; set; }

    }
    public class Operation5
    {
        public Operation5()
        {
            this.Details = new Details4();
        }
        public Details4 Details { set; get; }
    }
    public class Details4
    {
        public Details4()
        {

            this.RESOURCECUSTOMFIELD = new List<RESOURCECUSTOMFIELD>();
        }
        [HiddenInput(DisplayValue = false)]
        public string RESOURCENAME { set; get; }
//code goes here....

now i have the following inside a Main view :-

 @model S.ViewModels.ServerJoin
 @Html.EditorFor(model=>model.operation.Details)

and i have created a view under the Shared/EditorTemplete folder named Details4.cshtml:-

@model S.ViewModels.Details4
@Html.EditorFor(model => model.RESOURCENAME)
@Html.ValidationMessageFor(model => model.RESOURCENAME)

now i was expecting that inside my MAIN view the following @Html.EditorFor(model=>model.operation.Details) should render the view named Details4.cshtml defined inside the EditorTemplete ? but it did not? so can anyone adivce on this please?

Thanks


Solution

  • It's Shared/EditorTemplates not Shared/EditorTemplete.