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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:16:47+00:00 2026-05-20T10:16:47+00:00

When the user clicks the submit button on a form I want to return

  • 0

When the user clicks the submit button on a form I want to return a success / failure message to the user and i’m wondering what the best way to send the message back to the user is.

For example on a login form if the user enters an incorrect password i’d want the view to reload with a message telling them that login failed. Or on an update form the original view they had would show up with a message saying update was successful.

My idea is to have a few partial views or HTML helpers that look for a ViewBag property like “ErrorMessage” or “SuccessMessage” and conditionally show themselves when these properties have a value. These components could be added to the _Layout or manually each form where they are required.

Edit

I have since found out that the ValidationSummary method takes a parameter of whether to exclude property errors which means you can use it to show when login / registration has failed. But there seems to be a bug where the validation summary is still generated even if there are no errors.

  • 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-20T10:16:48+00:00Added an answer on May 20, 2026 at 10:16 am

    This is a good question and one that I’ve been trying to solve in a new MVC application recently. For me, ModelState.AddModelError is ok for errors but doesn’t work when communicating things like success or warning messages.

    Here’s an approach that I decided to take recently and I welcome any feedback on it:

    1. I created a class called Notification and an enum called NotificationType. NotificationType has 4 values: Success, Error, Warning, & Info. Notification has the properties ‘Message’ and ‘Type’.

    2. I have a static class called NotificationManager that holds instances of Notification objects for the life of an HttpRequest (using the user’s Session object). The idea is that any controller can add any number of Notification objects during the execution of an Action depending on what it needs to “tell” the user.

    3. I have a custom HtmlHelper which I call once in a master page (i.e. Html.NotificationSummaryFor()) that takes a IEnumerable of Notifications (i.e. NotificationManager.Notifications) and renders a UL with child LI’s for every Notification. I then use CSS classes to style those notification LI’s based on the ‘NotificationType’ (Red for Error, Yellow for Warning, Green for Success, etc). The HtmlHelper is also responsible for clearing the notifications from the manager after rendering them to the View.

    This implementation is pretty simple and has limitations but in general, I find that having a framework like this ensures that a team of developers working on the same application are able to provide notifications in a consistent fashion which is important to usability and maintainability.

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

Sidebar

Related Questions

When the user clicks the submit button on a form I want to return
When a user clicks a submit button I want the form to be submitted.
Details: Only disable after user clicks the submit button, but before the posting back
I have a form, when the user clicks on the submit button this javascript
If the user manually clicks the 'submit' button, i use this code: if (isset($_POST['submit_findall']))
I have an ASP.NET MVC application, when a user clicks on the submit button
I have an HTML page with a simple form. When the user clicks submit,
When the user clicks a button, I want his browser to automatically scroll to
I want to have a confirmation from the user before they submit a form.
I've got a form that is using jQuery validation. When the user clicks the

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.