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 8124799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:35:01+00:00 2026-06-06T06:35:01+00:00

Suppose I have a parent.cshtml view with a parentModel, and a child.cshtml view with

  • 0

Suppose I have a parent.cshtml view with a parentModel, and a child.cshtml view with a childModel.
This child action is [ChildActionOnly] and is rendered in parent.cshtml: @Html.Action("ChildAction").

Now, in controller/ParentAction

public ActionResult ParentAction() {return View();}
[HttpPost] 
public ActionResult ParentAction(ParentModel parentmodel) { 
    if(!ModelState.IsValid) {
      ...
      ModelState.AddModelError("", "parent view has an error");
    }
    return View(parentmodel); // pass the ball back to user
}

in controller/ChildAction

[ChildActionOnly]
public ActionResult ChildAction() {return View();}
[HttpPost] 
public ActionResult ChildAction(ChildModel childmodel) { 
     if(!ModelState.IsValid) {
       ...
       ModelState.AddModelError("", "child view has an error");
    }
    //??? return ParentView(parentmodel, childmodel) ??? how do i do this??? 
}

In the child action, how do I return to the ParentView (that also renders the ChildView), and preserve the data in their models?

EDIT:—–

My point is how not to do that. return View(childmodel); from child action will not get us what we want to see, because it will only give us a ‘partial’ page with child view only, the parent part is missing. RedirectToAction("ParentAction"); will give us full view again, but it will lose the models. Not sure how to handle returning models in nested views. That’s where I am stuck.

  • 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-06-06T06:35:02+00:00Added an answer on June 6, 2026 at 6:35 am

    First you have to create a common model that wraps the ParentModel and ChildModel else put the ChildModel as a property of the ParentModel. Instead of calling a child action and render the child view I would suggest you use Html.RenderPartial in this case.

    Let say the ParentModel wraps the ChildModel then from the ParentView.cshtml you could render the ChildView.cshtml by,

    @Html.Partial("ChildView", Model.ChildModel);
    

    Now from the child post action you have to build the ParentModel and return the ParentView.

    [HttpPost] 
    public ActionResult ChildAction(ChildModel childmodel) { 
        if(!ModelState.IsValid) 
        {
           ...
           ModelState.AddModelError("", "child view has an error");
        } 
    
        ParentModel model = .. build the model from querying database.
    
        return View("ParentView", model);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have this table parent | child 1 2 1 3 2 4
suppose I have a html markup like this: <div> <p> this is the parent
Suppose we have 2 classes, Child, and the class from which it inherits, Parent.
Suppose I have two tables in a parent - child relationship. Let's call them
Let's suppose I have a parent class in PHP like this: class A {
suppose I have a nested tables in html like this <table> <tr> <td><table> <tr>
Suppose I have public class Parent { private IList<Child> _children; public void AddChild(Child child)
Suppose I have a process which spawns exactly one child process. Now when the
Suppose I have a table with parent-child relationships. parent child 1 4 1 5
Suppose we have the following table data: ID parent stage submitted 1 1 1

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.