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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:47:12+00:00 2026-06-14T00:47:12+00:00

I have a problem with MVC3 model validation and DataAnnotations I have the following

  • 0

I have a problem with MVC3 model validation and DataAnnotations

I have the following classes:

public class A
{
    public C SomeProperty {get;set;}
}

public class B
{
    [Required]
    public C SomeProperty {get;set;}
}
public class C
{
    [Required]
    public string SomeSubProperty {get;set;}
}

This is because C can be required for some objects and not required for others, but if C is required i want SomeSubProperty to also be required.

However when i call ModelState.IsValid in my controller it will return false when using both A and B as models if SomeSubProperty is not set. Is there any way i can produce this behaviour?

  • 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-14T00:47:13+00:00Added an answer on June 14, 2026 at 12:47 am

    I don’t normally mix “Domain Model” with “View Model”.

    Domain model reflects business relationship and it can be very complex whereas view model suppose to be very flat and doesn’t have deep levels of dependencies so that you are able to use Annotations.

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

Sidebar

Related Questions

I am using MVC3 and added model validation with required attributes. Then I have
I have a curious problem with ASP.NET MVC3 client-side validation. I have the following
I have a problem with a model in a asp.net mvc3 application. First of
i have a problem with my mvc3 application, i need to create some Validation
I have a register form created by mvc3 scaffolding. e.g. <div class=editor-label> @Html.LabelFor(model =>
i have a problem with the asp.net MVC3. when i create a new project
Using MVC3 with NHibernate, I am having a problem with dropdowns. I have a
I have problem with repopulating form_upload after validation. Other input fields or selectboxes are
I have a class library that has it's own model and connectionstring to the
I Have a little problem with WebGrid control for Asp.Net MVC3. What I want

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.