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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:26:22+00:00 2026-06-04T13:26:22+00:00

I have a ViewModel class composed of several nested classes: public class UserAccountViewModel :

  • 0

I have a ViewModel class composed of several nested classes:

 public class UserAccountViewModel : UserProfileViewModel
    {
        public UserAccountEmailViewModel UserAccountEmail { get; set; }
        public UserAccountLocationViewModel UserAccountLocation { get; set; }
        public UserAccountPasswordViewModel UserAccountPassword { get; set; }
    }

The HTML rendered from this (pay attention to model.UserAccountEmail.Email):

<div class="editor-label">
        @Html.LabelFor(model => model.UserAccountEmail.Email)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.UserAccountEmail.Email)
        @Html.ValidationMessageFor(model => model.UserAccountEmail.Email)
    </div>

Is this:

name="UserAccountEmail.Email"

I would prefer the name to simply be Email

Changing ViewData.TemplateInfo.HtmlFieldPrefix didn’t help. Overloading the htmlFieldName in @Html.EditorFor isn’t going to work because I still want the label and validation message to match the rendered HTML element (no overload for htmlFieldName in these functions).

I’d prefer to not create partials for this.

Edit:

Meh…using partials actually isn’t too bad. It actually makes quite a lot of sense.

  • 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-04T13:26:24+00:00Added an answer on June 4, 2026 at 1:26 pm

    See my answer here about this design, it might make sense for this particular strategy

    Many models to view with many partial views

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

Sidebar

Related Questions

I have a viewmodel. public class RegistrationViewModel { public RegisterModel Register { get; set;
Suppose you have a viewModel: public class CreatePersonViewModel { [Required] public bool HasDeliveryAddress {get;set;}
I have the following ViewModel public class NewCustomerViewModel { public long CustomerId {get;set;} public
I have a ViewModel: public class Page { public int Id { get; set;
I have the following ViewModel public class RecommendationModel { public List<CheckBoxItem> CheckBoxList { get;
Suppose I have ViewModel like public class AnotherViewModel { public string Name { get;
I have following ViewModel: public class Bulletin1ViewModel { [Required] public String NumberDelegations { get;
I have the following ViewModel public class ShowQuestionsViewModel { public String CategoryName { get;
I have viewmodel which i am contructing in a Create get action, public class
I have 2 properties in my ViewModel class ViewModel1 { Dictonary<int, string> PossibleValues {get;set;}//key/value

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.