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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:36:30+00:00 2026-05-12T14:36:30+00:00

In a ValidationSummary, why are the messages shown in a different order than the

  • 0

In a ValidationSummary, why are the messages shown in a different order than the order you added errors to the ModelState and how might I fix this?

  • 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-12T14:36:30+00:00Added an answer on May 12, 2026 at 2:36 pm

    asp.net mvc is open source so you can see the code for ValidationSummary directly.

    http://www.asp.net/mvc/download/

    That said, I’m pretty sure ModelState is a dictionary. So if ValidationSummary is iterating over the key/values in the ModelState dictionary looking for errors the order is going to be random.


    I downloaded the code at work. From ValidationSummary in MVC/Html/ValidationExtensions.cs:

    foreach (ModelState modelState in htmlHelper.ViewData.ModelState.Values) {
        foreach (ModelError modelError in modelState.Errors) {
            // stuff to build a string with the error
        }
    }
    

    So it is iterating over the values in the dictionary. And from MSDN:

    For purposes of enumeration, each item in the dictionary is treated as a KeyValuePair(TKey, TValue) structure representing a value and its key. The order in which the items are returned is undefined.

    and

    The order of the values in the Dictionary(TKey, TValue).ValueCollection is unspecified

    Emphasis mine.

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

Sidebar

Related Questions

By default Html.ValidationSummary() produces HTML like this: <span class=validation-summary-errors>There were some errors...</span> <ul class=validation-summary-errors>
How can I display the asp:ValidationSummary messages in Hebrew? Should I override it or
how to append error messages on validation summary through javascript. i have added a
I want to have the ValidationSummary errors displayed during Client Side validation. Currently the
Html.ValidationSummary() is still being rendered even if the model state is valid. This example
Has anyone ever seen this and does anyone know how to fix it ...
The .NET ValidationSummary control aggregates error messages from validators that are fired on postback.
I have a question about ModelState and validation error messages in MVC3. I have
Client side Validation and ValidationSummary is working fine for my project (MVC4 + Razor
I have a custom user control that contains asp:ValidationSummary . It is placed on

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.