0

I really don't know why this is happening. Validation Summaries seem like very basic controls. After I click the "Submit" button, the individual error messages appear nex to the fields (for instance, when a field is required, the error message saying "Field Required" appears next to the textbox), but nothing appears where my validation summary should be. I don't have any Validation Groups because I want to validate everything on the page. Everything on my page looks and works fine. I just can't seem to figure out what could possibly be preventing the summary from displaying. The validation summary is at the top of the page. Here's my code:

<form id="form1" runat="server">

  <asp:ValidationSummary
  id="valSum" 
  DisplayMode="BulletList"
  runat="server"/>

<div id ="name">




 <asp:Label
 id="lblFirstName"
 Text="First Name:"
 AssociatedControlID="txtFirstName"
 Runat="server" />
 <br />
 <asp:TextBox
 id="txtFirstName"
 Runat="server" />
 <asp:RequiredFieldValidator
 id="reqFirstName"
 ControlToValidate="txtFirstName"
 Text="(Required)"
 Runat="server" />
    </div>
 <div>
 <asp:Label
 id="lastName"
 text="Last Name:"
 runat="server" />
 <br />
 <asp:TextBox
 id="txtLastName"
 Runat="server" />
 <asp:RequiredFieldValidator
 id="reqLastName"
 ControlToValidate="txtLastName"
 Text="(Required)"
 Runat="server" />

 <br /><br />

 <asp:Label
 id="city"
 text="City:"
 runat="server" />
 <br />
<asp:TextBox
 id="txtCity"
 Runat="server" />
 <asp:RequiredFieldValidator
 id="reqCity"
 ControlToValidate="txtCity"
 Text="(Required)"
 Runat="server" />

 <br /><br />

 <asp:Label
 id="state"
 text="State:"
 runat="server" />
 <br />
<asp:TextBox
 id="valState"
 MaxLength="2"
 Width="20"
 Runat="server" />
 <asp:CustomValidator
 id="reqState"
 ControlToValidate="valState"
 OnServerValidate="stateArrayCheck"
 Text="Please enter a valid U.S. State (using all caps)"
 Runat="server" />

 <br /><br />

 <asp:Label
 id="Label1"
 text="Zip Code"
 runat="server" />
 <br />
<asp:TextBox
 id="zipText"
 Runat="server"
 width="40" />
 <asp:RangeValidator
 id="reqZip"
 ControlToValidate="zipText"
 Text="Must be a valid zip code between 40000 and 59000"
 MinimumValue="40000"
 MaximumValue="59000"
 Runat="server" />

 <br /><br />

 <asp:Label 
 id="lblPhone"
 Text="Phone Number:"
 AssociatedControlID="txtPhone"
 Runat="server" />
 <br />
 <asp:TextBox
 id="txtPhone"
  Runat="server" />
 <asp:RegularExpressionValidator
 id="regPhone"
 ControlToValidate="txtPhone"
 Text="(Invalid Phone Number. Please use the format 555-555-5555)"
 ValidationExpression="[0-9]{3}-[0-9]{3}-[0-9]{4}"
 Runat="server" /> 

 <br /><br />

 <asp:Label 
 id="lblEmail"
 Text="Email Address:"
 AssociatedControlID="txtEmail"
 Runat="server" />
 <br />
 <asp:TextBox
 id="txtEmail"
 Runat="server" />
 <asp:RegularExpressionValidator
 id="regEmail"
 ControlToValidate="txtEmail"
 Text="(Invalid email)"
 ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
 Runat="server" /> 

 <br /><br />

 <asp:Label
 id="lblHours"
 text="Hours Worked"
 runat="server" />
 <br />
 <asp:TextBox
 id="txtHours"
 Runat="server"
 width="40" />
 <asp:RangeValidator
 id="RangeValidator1"
 ControlToValidate="txtHours"
 Text="Enter a valid number of hours (must be between 10 and 60)"
 MinimumValue="10"
 MaximumValue="60"
 Runat="server" />

 <br /><br />

 <asp:Label 
 ID="lblStartDate"
 Text="Start Date:"
 Runat="server" />
 <asp:TextBox
 id="txtStartDate"
 Runat="server" />

 <br /><br /> 

 <asp:Label 
 id="lblEndDate"
 Text="End Date:"
 Runat="server" />
 <asp:TextBox
 id="txtEndDate"
 Runat="server" />
 <asp:CompareValidator
 id="cmpDate"
 Text="(End date must be greater than start date)"
 ControlToValidate="txtEndDate"
 ControlToCompare="txtStartDate"
 Type="Date"
 Operator="GreaterThan"
 Runat="server" />

<br /><br />



 <asp:Button
 ID="btnSubmit"
 Text="Submit"
 Runat="server" />


</div>
</form>
</body>
</html>
2
  • I have edited your title. Please see, "Should questions include “tags” in their titles?", where the consensus is "no, they should not". Commented Nov 26, 2014 at 22:19
  • OK, thanks for notifying me. I'll keep that in mind for the future. Commented Nov 26, 2014 at 22:22

1 Answer 1

2

You need set the ErrorMessage in your validators like this:

 <asp:RequiredFieldValidator ErrorMessage="Fist name is required" ...
Sign up to request clarification or add additional context in comments.

1 Comment

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.