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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:51:40+00:00 2026-05-21T07:51:40+00:00

I have a situation in ASP.NET MVC 2 where I have a form whose

  • 0

I have a situation in ASP.NET MVC 2 where I have a form whose fields are based on info supplied by a view model, but whose posted data is a subset of that data represented by a slimmer edit model. I’d like to add simple data annotation validation to the edit model, but since the view is based on the view model, I’m not sure how to proceed.

  • 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-21T07:51:41+00:00Added an answer on May 21, 2026 at 7:51 am

    View model and controller action parameters don’t have to be the same.

    In your case this means that you may be using a richer model class to generate your view (and maybe even posting more information than needed) but your controller action would only use some information from that posted data to populate a simpler application model object instance. No problem. As long as field naming will suffice to populate properties correctly.

    You may have these two classes:

    public class User
    {
        [Required]
        public string Username { get; set; }
    
        [Required]
        public string Password { get; set; }
    }
    
    public class Person: User
    {
        public string Name { get; set; }
    
        public string Address { get; set; }
    }
    

    and then your view would be using Person and your controller action would have a parameter of type User. Fine. It will work.

    There’s no need for these classes to inherit each other either. I’ve just made it so in this simple example because this way they both share common property names. But otherwise they don’t have to be related in any way shape or form as long as posted field names will be able to model bind to controller action parameter class properties.

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

Sidebar

Related Questions

I have an interesting situation where I need to deploy an ASP.NET MVC app
Have just started playing with ASP.NET MVC and have stumbled over the following situation.
I have an ASP.Net MVC Page with a very simple form on it: One
Here's the situation... Site 1) ASP.NET MVC application for customers to login, view and
I am just starting to learn ASP.NET MVC and I have a situation where
I am working on a asp.net mvc application. I have a situation where I
What's the best method for handling a situation where you have an ASP.Net Dropdownlist
I have a wizard in my asp.net MVC application which is built upon this
I have an asp.net mvc calendar application (using jquery ui datepicker) and i am
I have an ASP.NET MVC 2 web site, the site.master declares <!DOCTYPE html PUBLIC

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.