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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:30:19+00:00 2026-05-17T00:30:19+00:00

I am using ASP.NET MVC. My requirement is to build a complex object (an

  • 0

I am using ASP.NET MVC. My requirement is to build a complex object (an object made of other object) through a step-by-step procedure like in a wizard.

Every dependent object shall be build on it’s step and shall be validated in it’s step. For example

public class ComplexObjectModel {
    public Object1 MyObject1 { get; set; }
    public Object2 MyObject1 { get; set; }
    public Object3 MyObject1 { get; set; }
}

As there is no built-in facility for a wizard I have decided to create 3 model classes and 3 strong typed partial views binded to these models.

On every step of my pseudo wizard I validate the dependent model object and set the property of the complex object to its reference.

I was thinking to save the complex object inside the ViewData/TempData in the following way

In the controller action

[HttpPost]
public ActionResult MyAction1() {
    ComplexObjectModel com = (ComplexObjectModel)ViewData["ComplexObjectModel"];
    com.MyObject1 = new Object1();
    ViewData["ComplexObjectModel"] = com;
    return PartialView( "MyAction2", com.Object1 );
}

and in the View

<% using (Html.BeginForm()) { %>
    <%= Html.Hidden("ComplexObjectModel", ViewData["ComplexObjectModel"]) %>

    ... view fields for Object1, Object n ....
<% } %>

But doing this way the object is not passed back-and-forth between the view and the controller and I have experienced that is null when it comes back from the view to the next action.

Is there a way to support this requirement?

thanks for helping

  • 1 1 Answer
  • 1 View
  • 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-17T00:30:19+00:00Added an answer on May 17, 2026 at 12:30 am

    There are a couple of ways I might tackle this.

    First; I might decide to store all this in the session object. I am assuming here that the models are quite large and so I wouldn’t want them stored on the view and passed back each time I go to the next page.

    Second; I might store them in the database and if the wizard didn’t complete then delete them as part of a background process.

    The one thing I wouldn’t do is pass the complex object to each view. The view should really need to know anything about any other view in a restful world and so I’d be inclined not to do it.

    Of course that does mean you need to decide a storage place for the data. If I had a Large objcect then I’d choose the database and if was fairly small then I’d choose the session object.

    As you have already found, having all the data for each object in each view can be problematic.

    However, if you are determined to do this the View way then here is what I’d do;

    1. Create a partial view which deals
      only with each object in the complex
      model.
    2. On each view, include all three, or
      more, of the partial views.
    3. For each partial view which is not
      an active participant in the view,
      place it within a div that is
      hidden.

    At least then when you change a property, or add one, you simply set it in the partial view once and not three times. Also if there is an error, you can unhide the divs and see if the data is coming in.

    Also each field should then have the id of ModelName.Property so that the controller knows where the property is.

    <%= Html.TextBox("MyObject1.MyProperty1", value) %>
    

    Then in the controller you simply do, and this off the cuff;

    [HttpPost]
    public ActionResult MyAction1(ComplexObjectModel complexModel) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.NET MVC in a project and I have a requirement like this..
i m using a jqgrid on asp.net mvc... i have a specific requirement....The data
I'm developing an ASP.NET MVC 3 project using NInject to create object instances. It
I am using ASP.Net MVC 3 Razor view engine. I have a requirement to
I am using ASP.NET MVC 4 and would like to know if there is
Using ASP.Net MVC on my Site.Master I have: <head runat=server> <title><asp:ContentPlaceHolder ID=TitleContent runat=server />
Using ASP.NET MVC when trying to get the information stored on my Session[objectName] from
Using ASP.NET MVC 2.0, I have an actionlink that is used for comments on
Using ASP.NET MVC + jQuery : I need to use some values owned by
Using ASP.Net MVC 2, is there any way to use the RedirectToAction() method of

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.