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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:30:56+00:00 2026-06-03T01:30:56+00:00

I am making my first tentative steps into MVC3 and have come across an

  • 0

I am making my first tentative steps into MVC3 and have come across an issue with the translation of navigation properties within a model to a view. It seems that in the view navigational properties do not allow client side validation nor is the “Display” label attribute picked up.

I have the following simple model:

public class Entity
{
    [Key,
    ScaffoldColumn(false)]
    public int Entity_Id { get; set; }

    [Display(Name = "Entity Name"),
    Required(ErrorMessage = "Please enter the entity name."),
    StringLength(150, ErrorMessage = "Please ensure that the entity name is under 150 characters.")]
    public string Entity_Nm { get; set; }

    [Display(Name = "Entity Type"), 
    Required(ErrorMessage="Please select the entity type"),
    ForeignKey("EntityType")]
    public int EntityType_Id { get; set; }

    public virtual EntityType EntityType { get; set; }
}

Which references this model:

public class EntityType
{
    [Key]
    public int EntityType_Id { get; set; }

    [Display(Name = "Entity Name"), Required(ErrorMessage="Please enter the entity type name.")]
    public string EntityType_Nm { get; set; }
}

When I create a controller with read/write actions and views for this model I get the following create form:

<fieldset>
    <legend>Entity</legend>

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

    <div class="editor-label">
        @Html.LabelFor(model => model.EntityType_Id, "EntityType")
    </div>
    <div class="editor-field">
        @Html.DropDownList("EntityType_Id", String.Empty)
        @Html.ValidationMessageFor(model => model.EntityType_Id)
    </div>

    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>

This is fine apart from the label for the Entity Type drop down, for some reason it is not picking up the “Display” attribute of the navigation property within the model (note the lack of a space). Also client side validation is not enabled for the dropdown list (server side validation works without issue) despite decorating the property with a “Required” attribute. Client side validation works on the other fields. Please note that all the required .js script files have been included and I have also added the relevant enable validation keys to the web.config.

Any ideas what I am missing here? Thanks one and all.

  • 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-03T01:30:57+00:00Added an answer on June 3, 2026 at 1:30 am

    for DropDownList Display issue just try below

    @Html.LabelFor(model => model.EntityType_Id)

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

Sidebar

Related Questions

I'm making my first baby steps with unit testing and have written (among others)
I'm making my first game in canvas/JS and I'm running into an issue with
I'm making my first foray into WPF - I have a simple form with
Making my first steps with NHibernate, I'm trying to have it creating my Tables
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
I'm making my first steps with unit testing and am unsure about two paradigms
I am making my first foray into scala for a production app. The app
I have trying to get around making my first C# application(that can do more
I'm making my first steps with JPA (eclipselink) developement, and i'm wondering if there's
I have create a web application using CodeIgniter making at first a login interface.

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.