ASP.NET validation summary

· Read in about 1 min · (171 words) ·

The ASP.NET validation summary is great for displaying all the errors in the page. It would be nice though to be able to use a validation summary to display errors that occur on the server side.

A typical scenario is when you have a page that does a search and then displays the results of the search. For the case where no results are found, it would be nice to be able to display the results in our custom validation summary control. It takes away the need to handle the display of the error message in a validation summary control.

This is what you can do about it - implement the IValidator class

public
class CustomErrorMessage:IValidator
        {
                privatestring message;
                public CustomErrorMessage()
                {
                        //
                        // TODO: Add constructor logic here
                        //
                }
                #region IValidator Members

                publicvoid Validate()
                {
                        // TODO: Add CustomErrorMessage.Validate
implementation
                }

                publicbool IsValid
                {
                        get
                        {
                                returnfalse;
                        }
                        set
                        {
                                
                        }
                }

                publicstring ErrorMessage
                {
                        get
                        {
                                
                                return message;
                        }
                        set
                        {
                                this.message = value;
                        }
                }

                #endregion
        }