【问题标题】:Defining a View inisde the shared/EditorTemplete folder is not working on my asp.net mvc-4 web application在我的 asp.net mvc-4 Web 应用程序上定义共享/EditorTemplete 文件夹中的视图不起作用
【发布时间】:2016-10-15 09:38:14
【问题描述】:

我正在开发一个 asp.net mvc-4 Web 应用程序。现在我有以下视图模型类:-

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

CreateResource 类如下:-

 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....

现在我在主视图中有以下内容:-

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

我在 Shared/EditorTemplete 文件夹下创建了一个视图,名为 Details4.cshtml:-

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

现在我期待在我的 MAIN 视图中,以下 @Html.EditorFor(model=&gt;model.operation.Details) 应该呈现在 EditorTemplete 中定义的名为 Details4.cshtml 的视图?但它没有?那么有人可以就此提出建议吗?

谢谢

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-4 razor asp.net-mvc-5 mvc-editor-templates


    【解决方案1】:

    这是Shared/EditorTemplates 而不是Shared/EditorTemplete

    【讨论】:

      猜你喜欢
      • 2014-03-05
      • 1970-01-01
      • 2013-01-16
      • 2012-12-01
      • 1970-01-01
      • 2013-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多