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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:28:15+00:00 2026-05-17T22:28:15+00:00

I am developing an ASP.NET MVC2 application in which I have a User class

  • 0

I am developing an ASP.NET MVC2 application in which I have a User class with a property named SecurityQuestionID as follows:

public class User
{
    [RangeAttribute(1, 5, ErrorMessage = "Security Question is required")]
    [DisplayName("Security Question")]
    public virtual int SecurityQuestionID { get; set; }
}

The SecurityQuestionID field gets populated from a dropdown in the view as follows:

<%: Html.LabelFor(model => model.SecurityQuestionID)%>
<%: Html.DropDownListFor(model => model.SecurityQuestionID, ViewData["securityQuestions"] as SelectList,"Choose a Question",null) %>
<%: Html.ValidationMessageFor(model => model.SecurityQuestionID)%>

The controller sends the security questions to the view by using view data as follows:

ViewData["securityQuestions"] = new SelectList(_securityQuestionService.GetAll(), "SecurityQuestionID", "Question");

If I don’t select a question from the dropdown and hit the submit button, then “The Security Question field is required.” message is displayed instead of “Security Question is required“. Can anyone help me understand what I am doing wrong here?

  • 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-17T22:28:16+00:00Added an answer on May 17, 2026 at 10:28 pm

    If the integer is not nullable, then it is required by default. So the range validation isn’t failing but Required validation is failing.
    You may want to specify a separate error message for when it is required by adding a required attribute.

    [Required(ErrorMessage="Security Question is required")]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing asp.net mvc2 application and I use asp.net membership provider which uses
I'm currently developing an asp.net mvc 2 application which uses the default SqlMembershipProvider for
I developing ASP.NET application using a Swedish version of Windows XP and Visual studio
I have been developing in asp.net since its existence (also classic asp before that)
I am developing an ASP.NET MVC application and I want to use OpenId. What
I'm developing a new ASP .NET website which is effectively a subset of the
I am developing the ASP.NET MVC 2 application . I want to show the
I am developping an intranet ASP.NET MVC2 application for a small business. The small
I am developing an ASP.NET Ajax form, and decided to make most of the
We are developing large ASP.NET applications with lot of dynmically created pages containing ASCX

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.