Share via

validation control

zal wel 20 Reputation points
2026-04-01T14:44:42.09+00:00

how to supress the errir message of the normal valudation controls and only show the error messages from the summary control?

<%@ Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      Name:<br/>
      <asp:textbox id="NameTextBox"
        runat="server"/>
        
      <asp:requiredfieldvalidator id="NameTextBoxRequiredValidator"
        controltovalidate="NameTextBox"
errormessage="Name field."
        
        
        
        runat="server"/>     
        
      <br/>  
      
      City:<br/>
      <asp:textbox id="CityTextBox"
        runat="server"/>
        
      <asp:requiredfieldvalidator id="CityTextBoxRequiredValidator"
        controltovalidate="CityTextBox"
        errormessage="City field."
       
        
        runat="server"/> 
        
      <br/>
      
      <asp:Button id="SubmitButton"
        text="Submit"
        runat="server"/>
      
      <hr/>
      
      <asp:ValidationSummary 
        id="valSum" 
        displaymode="BulletList" 
        headertext="You must enter a value in the following fields:"
        runat="server"/>
    
    </form>
  </body>
</html>
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Jack Dang (WICLOUD CORPORATION) 16,040 Reputation points Microsoft External Staff Moderator
    2026-04-02T03:59:11.9866667+00:00

    Hi @zal wel ,

    Thanks for reaching out.

    In ASP.NET Web Forms, each validation control can display its error message both inline (next to the input) and in the ValidationSummary.

    If you want to suppress the inline messages and only show them in the ValidationSummary, you can set Display="None" on each validator.

    For example:

    <asp:RequiredFieldValidator
        ID="NameTextBoxRequiredValidator"
        runat="server"
        ControlToValidate="NameTextBox"
        ErrorMessage="Name field."
        Display="None" />
    
    <asp:RequiredFieldValidator
        ID="CityTextBoxRequiredValidator"
        runat="server"
        ControlToValidate="CityTextBox"
        ErrorMessage="City field."
        Display="None" />
    

    The ErrorMessage property is what gets picked up by the ValidationSummary. By setting Display="None", the validator will not render the message next to the textbox.

    Your existing ValidationSummary can remain unchanged.

    Alternatively, you can use the Text property for inline messages and keep ErrorMessage for the summary. However, if you want to completely suppress inline output, Display="None" is the simplest approach.

    Hope this helps! If my answer was helpful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.


  2. zal wel 20 Reputation points
    2026-04-01T23:59:02.9033333+00:00

    the errormessage appears next to the textboxes bybthe way

    0 comments No comments

  3. Q&A Assist
    2026-04-01T14:44:52.6633333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Set the validators’ Text property to an empty string (or omit it) and rely only on ErrorMessage, which is what ValidationSummary uses.

    For example:

    <asp:RequiredFieldValidator ID="NameTextBoxRequiredValidator"
        runat="server"
        ControlToValidate="NameTextBox"
        ErrorMessage="Name field." 
        Text="" />
    
    <asp:RequiredFieldValidator ID="CityTextBoxRequiredValidator"
        runat="server"
        ControlToValidate="CityTextBox"
        ErrorMessage="City field."
        Text="" />
    

    With Text empty, no inline message is rendered next to the controls, but the ErrorMessage values still appear in the ValidationSummary.


    References:


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.