Home     About PeterBlum.com     Policies     Download a Licensed Product     Newsletter
DES
CombinedErrorMessage Control
Back

The CombinedErrorMessage control lets you replace several individual validators with one that combines the error messages of those validators.

Note: The CombinedErrorMessage control requires a license covering Peter's More Validators module.

Using a CombinedErrorMessage control is easy. You can add it long after you setup the validators. Simply add it to the web form, identify the validators you want it to manage in its Validators property, and setup its ErrorFormatter. It will automatically hide the validators its using.


Demo

These two textboxes are designed to require at least 5 characters with only digits and letters (like a password might). They both use a TextLengthValidator and CharacterValidator. The second textbox uses a CombinedErrorMessages control to combine all of its validators. All validators and the CombinedErrorMessages control use the "Image with Alert" ErrorFormatter.

To use this demo, enter "!" into both textboxes and tab off. You will see two images to the right of the first textbox and only one to the right of the second.



ASP.NET Syntax for this demo

<asp:TextBox id=TextBox1 runat="server" />
<des:TextLengthValidator id="TextLengthValidator1" runat="server"
  ErrorMessage="Please enter at least 5 characters." ControlIDToEvaluate="TextBox1" Minimum="5">
  <ErrorFormatterContainer>
    <des:AlertImageErrorFormatter/>
  </ErrorFormatterContainer>
</des:TextLengthValidator>
<des:CharacterValidator id="CharacterValidator1" runat="server" 
 ErrorMessage="Only letters and digits are allowed." ControlIDToEvaluate="TextBox1" 
 Digits="True" LettersLowercase="True" LettersUppercase="True">
  <ErrorFormatterContainer>
    <des:AlertImageErrorFormatter/>
  </ErrorFormatterContainer></des:CharacterValidator>
<br/>
<asp:TextBox id=TextBox2 runat="server" />
<des:TextLengthValidator id=TextLengthValidator2 runat="server" 
 ErrorMessage="Please enter at least 5 characters." ControlIDToEvaluate="TextBox2" Minimum="5">
  <ErrorFormatterContainer>
    <des:AlertImageErrorFormatter/>
  </ErrorFormatterContainer>
</des:TextLengthValidator>
<des:CharacterValidator id="CharacterValidator2" runat="server" 
 ErrorMessage="Only letters and digits are allowed." ControlIDToEvaluate="TextBox2" 
 Digits="True" LettersLowercase="True" LettersUppercase="True">
  <ErrorFormatterContainer>
    <des:AlertImageErrorFormatter/>
  </ErrorFormatterContainer>
</des:CharacterValidator>
<des:CombinedErrorMessages id="CombinedErrorMessages1" runat="server" ListStyle="True">
  <ErrorFormatterContainer>
    <des:AlertImageErrorFormatter/>
  </ErrorFormatterContainer>
  <Validators>
    <des:ValidatorControlConnection ControlID="TextLengthValidator2" />
    <des:ValidatorControlConnection ControlID="CharacterValidator2" />
  </Validators>
</des:CombinedErrorMessages>


Back