patsy2k
patsy2k

Reputation: 611

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

Upvotes: 1

Views: 25

Answers (0)

Related Questions