?
Solved

c#, asp.net- Group validation for a form, one error message for all fields

Posted on 2009-04-15
4
Medium Priority
?
743 Views
Last Modified: 2012-05-06
Hi,
I have a form on my aspx page that has several fields , I want to make sure each field is filled in before submiting. I have the group validation on each text input box and the same group validation on the button, but I want an error message to show when the submit button is clicked and the validation group is not valid( not all fields have been filled in)
Is this possible?
Thanks
<div>
                                	<label for="eventName">Event Name: *</label> <asp:TextBox ID="eventName" runat="server"></asp:TextBox>
                                	<asp:RequiredFieldValidator ID="RequiredFieldValidator7" ControlToValidate="eventName" ValidationGroup="RegisterValidation" runat="server"  Display="Dynamic" />
                                </div>
       
                                <div>
                                	<label for="venueName">Venue Name: *</label> <asp:TextBox ID="venueName" runat="server"></asp:TextBox>
                                	<asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="venueName" ValidationGroup="RegisterValidation" runat="server"  Display="Dynamic" />
                                </div>
 
<div>
                                	<label for="town">Town: *</label> <asp:TextBox ID="town" runat="server"></asp:TextBox>
                                	<asp:RequiredFieldValidator ID="RequiredFieldValidator69" ControlToValidate="town" ValidationGroup="RegisterValidation" runat="server"  Display="Dynamic" />
                                </div>
                                
 
 
 <asp:Button ID="SubmitButton" runat="server" OnClick="AddParkDetails" Text="Button" CssClass="submitButton" ValidationGroup="RegisterValidation"  />

Open in new window

0
Comment
Question by:CharlieDev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24146374
Hi

Use ValidationSummary control and set the properties
ShowMessageBox = true
ShowSummary = false
0
 

Author Comment

by:CharlieDev
ID: 24146414
Thanks , do you have an example of how I use it?
0
 
LVL 14

Accepted Solution

by:
GiftsonDJohn earned 2000 total points
ID: 24146663
I have included a validation summary control in your example.
 <div>
        <label for="eventName">
            Event Name: *</label>
        <asp:TextBox ID="eventName" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" ControlToValidate="eventName"
            ValidationGroup="RegisterValidation" runat="server" Display="Dynamic" />
    </div>
    <div>
        <label for="venueName">
            Venue Name: *</label>
        <asp:TextBox ID="venueName" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="venueName"
            ValidationGroup="RegisterValidation" runat="server" Display="Dynamic" />
    </div>
    <div>
        <label for="town">
            Town: *</label>
        <asp:TextBox ID="town" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator69" ControlToValidate="town"
            ValidationGroup="RegisterValidation" runat="server" Display="Dynamic" />
    </div>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="true" ShowSummary="false" ValidationGroup="RegisterValidation" />
    <asp:Button ID="SubmitButton" runat="server" OnClick="AddParkDetails" Text="Button"
        CssClass="submitButton" ValidationGroup="RegisterValidation" />

Open in new window

0
 

Author Closing Comment

by:CharlieDev
ID: 31570344
Thanks very much  :)
0

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question