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

  • Home
  • SEARCH
  • 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 3853036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:24:28+00:00 2026-05-19T17:24:28+00:00

I Posted the background to this question a few days ago.. but the answer

  • 0

I Posted the background to this question a few days ago.. but the answer is yet incomplete, so re-Posting with a summary.

I’m developing a MVC 3 Razor Web App, in which details of multiple categories of objects are stored. (Vehicles, Houses, Instruments etc) . All the objects share some common data (Title, Description etc) And some details which are specific to the category in which it belongs to. The Category list is expected to grow and in view of reducing maintainability we hope to reuse the same Add Object wizard . The wizard is based on the following implementation.

http://afana.me/post/create-wizard-in-aspnet-mvc-3.aspx

In the Multiple step wizard process , the final step allows the user to enter the category specific details (Model, Make, VIN etc for a Vehicle). The view page is bound to the “AssetView” Model, which is defined as follows

public class AssetView
{
    [Required]      
    public string Title { get; set;  }

    [Required]
    public string Description { get; set;}

    public SpecificAsset AssetDetails { get; set; }
}

the AssetDetails property will be dynamically changed at runtime according to the category type that is selected at a previous stage. the view looks like this

@model AssetView
....
<div class="wizard-step">
  ...
 </div>
<div class="wizard-step">
  ...
 </div>
<div class="wizard-step">
  @Html.EditorFor(model => model.AssetDetails)
 </div>

in the controller, based on category selection . i intialize assetdetails as follows

_thisAsset.AssetDetails = new MotorAsset();

I then override the views with type specific Editor templates.

The wizard works fine, but At the Save step in the controller the “AssetDetails” property has no values and it is shown to be of type “SpecificAsset” which is the base type. i’m unable to cast it to the specific type as well. However the formsCollection shows all values, the “AssetDetails” specific properties like “Transmission”, “Make” are in the forms collection prefixed by “AssetDetails_” .

Keeping in mind that i need to handle over 20 types of specific categories (Motor, House etc) at the controller save step, how can i do this without some kind of hack?

  • 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-19T17:24:28+00:00Added an answer on May 19, 2026 at 5:24 pm

    If you know the type of the AssetDetails you could do it like this:

    1. Take the AssetView as parameter to
      the action(binds the common
      properties)
    2. Create a new instance of the
      specific AssetDetails(for example
      CarDetails)
    3. Use one of the overloads of
      TryUpdateModel to bind the values.
      There are some overloads that let
      you specify prefix so it should
      always work
    4. Add this object to the
      AssetView.SpecificAsset

    You need some way to know the specific type. But I guess you would have a variable that tracks the type so you could save it properly later anyway. If you don’t it would be easy to add. Remember that it needs to be AssetView as AssetDetails are not being bound though.

    If you need validation there is a TryValidateModel you could try too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Posted a few answers on SO, but this is my first question :) Bit
I wrote an answer for this question: New background according to url , the
This is probably the worst question I have ever posted on Stack Overflow but
I posted a related question to no response but here I'll be less narrow.
I posted a related but still different question regarding Protobuf-Net before, so here goes:
(first posted on google group but no response so assuming I should be posting
I posted another one on this,, but i had to edit it really much...
This is probably a noob question that I will get slated for but here
I know that I was already posted similar question but I just can't find
I feel like this question has been asked before but the answers seem pretty

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.