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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:16:30+00:00 2026-05-28T05:16:30+00:00

I have a view model that looks like this: public class VenueIndexViewModel : BaseViewModel

  • 0

I have a view model that looks like this:

public class VenueIndexViewModel : BaseViewModel
{
    public VenueAddViewModel Venue;
    ...
}

public class VenueAddViewModel
{
    ...
    [Required(ErrorMessage = "This field is required")]
    public string State { get; set; }
    ...
}

In my view, I’m rendering a form with with a drop down list for this property like so:

using (var form = Html.BeginForm())
{ 
    ...
    @Html.DropDownListFor(x => x.Venue.State, Model.GetStates())
    @Html.ValidationMessageFor(x => x.Venue.State)
    ...
}

This works, but the problem is that the the Required attribute on the view model appears to be ignored. If I look at the HTML, the data-val-* attributes are missing as well.

<select id="Venue_State" name="Venue.State">...</select>

However, if I change the rendering to a textbox…

using (var form = Html.BeginForm())
{ 
    ...
    @Html.TextBoxFor(x => x.Venue.State)
    @Html.ValidationMessageFor(x => x.Venue.State)
    ...
}

I see the expected data-val-* attributes and the validation works:

<input data-val="true" 
    data-val-required="This field is required" 
    id="Venue_State" name="Venue.State" type="text" value="">

I should note that I have other view models elsewhere that use DropDownListFor with a flat view model (no nested objects) and the validation works fine there, so I’m thinking I’ve hit a bug in the MVC validation handling for drop down lists when using a nested view model. Can anyone confirm / advise?

  • 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-28T05:16:31+00:00Added an answer on May 28, 2026 at 5:16 am

    As far as I know you can’t have client side validation on nested objects. And a quick google search seems to confirm that.

    http://forums.asp.net/t/1737269.aspx/1

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

Sidebar

Related Questions

Let's say I have a model that looks like this: public class Blog {
I have a model that looks like this: public class UserAdminEditViewModel { public User
I have model that looks like this: public class Lesson { public int Id
I have a model that looks like this: public class Book { public string
I have a model that looks something like this: public class SampleModel { public
Ok, I have a ViewModel that looks like this: public class UserLogin { [Required]
I have a class that roughly looks like this: public class ViewModel { public
Well i have a complex form view model like this : public class TransactionFormViewModel
I have a class that looks like this: public class UserListVM { public SearchModel
I have a ViewModel that looks like this: public class CreateReviewViewModel { public string

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.