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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:14:47+00:00 2026-05-20T22:14:47+00:00

I have a ViewModel with a kinda complex data structure. I need my view

  • 0

I have a ViewModel with a kinda complex data structure. I need my view to render different partials, based on the type of elements in my viewmodel, kinda like this:

[Validator(typeof(ViewModelValidator))]
class ViewModel {
  IEnumerable<Element> Elements;
}
class Element {
  string DisplayName;
  DisplayType DisplayType; // TextBox, Select, Radiobutton, Checkbox
  IEnumerable<ElementValue> Values; // could be a list of values for the dropdown
  int Group;
  etc...
}
class ElementValue {
  ...
}

I need this structure to build my view that has dynamic input elements. When i submit the form i was thinking of sending a json representation of my form/values and have a ValueProvider(could be JsonValueProvider?) mapping the values to my ViewModel again. I only need the user added data, so i could just read the data or map it to a new object, but assuming i’m using FluentValidation (http://fluentvalidation.codeplex.com/wikipage?title=mvc) then i’d loose server-side validation right?

So i guess my question would be: should i map to my ViewModel, even though i lack all the information about Elements (besides the values entered) or should i just map to some object i can validate and then find some other way to show the errors client-side?

  • 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-20T22:14:47+00:00Added an answer on May 20, 2026 at 10:14 pm

    I dont know if this is the right way but , I have always felt that View Models should not be very complex. When it become complex we may using View Model View pattern but for the sake of using it.

    I usually Create View Model very specific to a View but with just enough Properties that I need to “read back” and are required for further processing (making decisions) . This includes hidden fields too. And as Validations are added using DataAnnotations lot of validation and mapping , MVC framework does which saves time.
    All data to view only elements like Grid , I send as Json.

    Regards,

    Mar

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

Sidebar

Related Questions

I have a registration page and would like to perform some validation (in addition
Using WPF and Prism. I have a view, containing 1 textblock <UserControl x:Class=ArmoryModule.Views.ResultsView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
I have a ViewModel setup to use RemoteValidation using the RemoteAttribute . It works
I have problems with how to do this. I have two classes; ProductViewModel and
I have a two pages say Main.xaml and Details.xaml .Each page has a ListBox
This is a wierd bug in my code and i have no idea what
I need a Telerik grid to only display records where the date recorded matches
I am trying to handle the http-post from a web form using MVC 2s
I've just read about MVC3's new CompareAttribute that you can apply to a model's

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.