Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
.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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda