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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:20:33+00:00 2026-05-12T09:20:33+00:00

I am trying to figure out how to notify the user which field failed

  • 0

I am trying to figure out how to notify the user which field failed to validate.
I setup LINQ to SQL class datacontext to access a database from ASP.net pages. Since user input will be from by web interface forms and import from Excel files, i would like the write the validation logic in one place. The idea behind this is when i import from excel. I will collect the error messages for each row, and display a summary, somehow. A logical place seems to extend the class generated by LINQ to SQL. According to most documentation and examples, i should do something like this:

public partial class Customer 
{
  partial void OnTitleChanging(string value) 
  {
    if (!Char.IsUpper(value[0])) {
      throw new ValidationException(
       "Title must start with an uppercase letter.");}
  }
}

The problem with this approach is that validation will stop on the first failed field.

In Windows Forms Link1, if I define an ErrorProvider component in the form and set the DataSource property of it to your BindingSource the exception will be indicated by a red circle right to the validated control. The tooltip of this red circle will show the exception message.

Is there something similar for ASP.net pages? I am using the listview control and inline editing in the listview.


Updates:
– I actually did something similar to what Nick Carver is suggesting. Link2 . Instead of throwing an exception, i record an error message.

public partial class PQSSClassesDataContext    
{
public partial class ErrorFeilds
  {
      private static List<string> Messages = new List<string>();
      public void AddErrorMessage(string message)
      {
          Messages.Add(message);
      }
      public List<string> GetErrorMessages() 
      {
          return Messages;
      }
  }
}

I am actually stuck on how to map the error message to the field. That’s why i was looking for something like ErrorProvider. I am already using events instead of exceptions to record errors. Any idea how to mark the corresponding failed field from the codebehind file?

Any help appreciated.

  • 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-12T09:20:33+00:00Added an answer on May 12, 2026 at 9:20 am

    What we have done in the past is simply have an error collection on the DataContext, extend it just adding something like a List<ValidationError>. Then all you need to do is override SubmitChanges() and check if you have any validation errors, and decide to abort, throw them, handle however you wish really at that point…all before calling base.SubmitChanges()

    We’re in a ASP.Net per-request life-cycle, but if your Context is around longer make sure to clear the error list.

    It’s handy for your ValidationError class/objects to contain a reference to a common base or interface that all your classes implement so you can point to the object later from the error if needed. (e.g. get the ID for throwing the error labels or other info in the right place).

    Example classes:

    public class ValidationError {
      public string Message { get; set; }
      public IBase { get; set; }
    }
    
    public interface IBase {
      public long ID { get; set; }
      public DateTime DateModified { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to figure out which to use.
Trying to figure out how to programmatically access the web pages in the application.
Trying to figure out why my list() class pointers are being overwritten with the
Trying to figure out how to apply a common class to jQuery Hover but
I'm trying to figure out a user friendly way to pass messages to users
I'm trying to figure out if there's a way I can somehow notify a
I am trying figure out the order in which the values in a HashMap
Trying to figure out how to get the current User's Full Name as entered
Trying to figure out out how to overload parenthesis on a class. I have
Trying to figure out an equation to get the current group a page would

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.