Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
.NET MVC error in EditorTemplate calling another EditorTemplate

I have a Aviewmodel that contains a child SignViewModel. and a Bviewmodel that also contains a child SignViewModel.

AViewModel:

public int id { get; set; }
public string name { get; set; }
//nav props
public virtual SignViewModel signVm { get; set; }

BViewModel:

public int id { get; set; }
public string name { get; set; }
//nav props
public virtual SignViewModel signVm { get; set; }

SignViewModel:

public int id { get; set; }
public string cert { get; set; }
public string pwd { get; set; }
//nav props
public virtual AViewModel aVm { get; set; }
public virtual BViewModel bVm { get; set; }

Then I have an editorTemplate for SignViewModel, that simply shows the 2 html fields:

EditorTemplates/SignViewModel.cshtml:

@Model MyProject.ViewModels.SignViewModel
@EditorFor(m => m.cert)
@EditorFor(m => m.pwd)

and also for AViewModel and for BViewModel:

EditorTemplates/AViewModel.cshtml:

@Model MyProject.ViewModels.AViewModel
@EditorFor(m => m.name)
...
@EditorFor(m => m.signVm)

EditorTemplates/BViewModel.cshtml:

@Model MyProject.ViewModels.BViewModel
@EditorFor(m => m.name)
...
@EditorFor(m => m.signVm)

This is working nicely. But now I need to change it so that in BViewModel.cshtml, instead of just including the SignViewModel editorTemplate, I need to have a bootstrap modal, and inside it, the SignViewModel. so I have created another EditorTemplate, SignModalViewModel: EditorTemplates/SignModalViewModel.cshtml:

@Model MyProject.ViewModels.SignViewModel
<div class="modal">
    ....
        @EditorFor(m => m)  --> this should load here EditorTemplate SignViewModel... but its not...
    ....
</div>

and I modified BViewModel.cshtml: EditorTemplates/BViewModel.cshtml:

@Model MyProject.ViewModels.BViewModel
@EditorFor(m => m.name)
...
@EditorFor(m => m.signVm, "SignModalViewModel")

but this is not working: AViewModel.cshtml works ok, but BViewModel.cshtml shows an empty modal... so it seems the line @EditorFor(m => m) (in SignModalViewModel.cshtml) is not working (I guess it does not find EditorTemplates/SignModalViewModel.cshtml)

what am I doing wrong??

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda