1
<asp:ValidationSummary ID="vsArea" runat="server" />
<div class="controls">
    <asp:DropDownList ID="ddlDegreeLevel" runat="server" 
                      placeholder="DegreeLevel" CssClass="form-control">
    </asp:DropDownList>
    <asp:RequiredFieldValidator ID="rfvDegreeLevel" runat="server"
                                ControlToValidate="ddlDegreeLevel"
                                Display="None" ForeColor="Red" InitialValue="-1"
                                ErrorMessage="Please select degree level" Text="">
    </asp:RequiredFieldValidator>
</div>

Errormessage of "rfvDegreeLevel" is show on validation-Summary and also below the control. I also set Display="None" but still show on both area .

I want to show message only on Validation summary.

1
  • I tried your code, everything is perfect and working as u want, plz save your file, and then refresh your browser and then check Commented May 13, 2014 at 7:06

1 Answer 1

1

This is by design...message will be shown in validation control and in the summary. Basically you have 2 options

  1. Show separate messages in your control and validation summary. E.g. you can put a red * in the validation control and detailed error message in the summary, which is a best practice. To achieve this, set both Text and ErrorMessage property of the validation control. Text will be appearing in the control and ErrorMessage will be appearing in the summary.

  2. hide the message from control, set the Display property of the control to none..

You have to add validationgroup to all the controls. For this you can use the following code:

<asp:ValidationSummary ID="vsArea" runat="server" ValidationGroup="degree" />
<div class="controls">
    <asp:DropDownList ID="ddlDegreeLevel" runat="server" 
                      placeholder="DegreeLevel" CssClass="form-control">
    </asp:DropDownList>
    <asp:RequiredFieldValidator ID="rfvDegreeLevel" runat="server"  
                                ValidationGroup="degree"
                                ControlToValidate="ddlDegreeLevel"
                                Display="None" ForeColor="Red" InitialValue="-1"
                                ErrorMessage="Please select degree level" Text="">
    </asp:RequiredFieldValidator>
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

how it is helpful? I mean he already mentioned he has used display ="None"
@Mehul adding ValidationGroup is not helpful in this scenraio

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.