Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6937575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:22:52+00:00 2026-05-27T12:22:52+00:00

I have the following model in MVC: public class IndexViewModel { public SubViewModel SubViewModel

  • 0

I have the following model in MVC:

public class IndexViewModel
{
    public SubViewModel SubViewModel { get; set; }
}

In my Index view I am doing the following to display an Editor for SubViewModel:

Index.cshtml

@model IndexViewModel

@Html.EditorFor(m => m.SubViewModel)

In my SubViewModel.cshtml file I tried to do the following:

EditorTemplates/SubViewModel.cshtml

@model SubViewModel

@Html.EditorForModel("SubViewModelForm")

Basically, I want to split apart my Editor into two pieces. The first editor template would create the form, and the inner one would create all of the actual form fields. The problem is that the inner view is never getting rendered.

It’s like MVC realizes that I already called EditorFor on that model and is preventing me from doing it again. Is there a way I can get this to work?

EDIT

I thought I typed out what was happening clearly but I guess not.

I want to use two templates to display a single model. In the first template, I want to render the form and the submit button, and a few container divs.

In the second template, I want to render all of the form fields.

Index.cshtml
@Html.EditorFor(m => m.SubViewModel) –> render the form and container

SubViewModel.cshtml
@Html.EditorForModel(“SubViewModelForm”) –> render the form fields

The problem is that the second call (@Html.EditorForModel(“SubViewModelForm”)) doesn’t seem to do anything. It never renders any tags at all. It is getting ignored by MVC.

The reason I want to do it this way is because I am going to be posting this form with an ajax call. If everything is okay (model state is valid) then I want to return JSON data to the view. If the model is invalid, I want to return the partial view with just the form fields. This way I don’t need to hook up all of my event handlers again. I can just replace the form fields instead of the entire view.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:22:53+00:00Added an answer on May 27, 2026 at 12:22 pm

    After reading your additional details I believe it would be best to use a container template template.

    /* Container.cshtml (container markup and call to editor template) */
    <fieldset>                    
        @Html.EditorForModel()
    </fieldset>
    
    /* SubViewModel.cshtml editor template */
    @model SubViewModel
    
    @Html.DisplayFor(x => x.Property1)
    @Html.EditorFor(x => x.Property1)
    ...
    
    /* Index.cshtml */
    @Html.RenderPartial("Container.cshtml", Model.SubViewModel)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an ASP.NET MVC application where I have the following model.. public class EventViewModel
I have the following model Person in my UI MVC layer: public class Person
Let's have a model public class Model { public int Number { get; set;
I have the following model in MVC: public class ParentModel { public string Property1
In the world of MVC I have this view model... public class MyViewModel{ [Required]
I’m developing MVC application and I have following classes in my model: public class
I am using Spring MVC 3, NetBeans I have the following model, public class
I have the following view model: Public Class MyViewModel Public Property SelectedIDs As List(Of
I have the following: public Class Vacancy{ public int VacancyID {get;set;} public List<Application> Applications
I have the following types and classes: namespace MVC.Models public class Page { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.