New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

ValidationSummary

Registration Form

First Name: *
Last Name: *
Skill Level:
Address: *

  • Demo Configurator
  • Choose Error Message Behavior:
    Dynamic
  • Set validation group of RadCaptcha

The RadCaptcha error message is displayed in the ValidationSummary when the ValidationGroup property of RadCaptcha, ValidationSummary and the Button that validates the captcha code input are set to the same value ("SubmitInfo" in the case). If the value is set to a different ValidationGroup (this can be done by unchecking the ValidationGroup Checkbox), the captcha does not validate the input.

Additionally, by setting the Display property (as in all page validators) you can choose whether to display the Error Message or not.

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page Language="vb" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Captcha.ValidationSummary.DefaultVB"CodeFile="DefaultVB.aspx.vb"  %>

<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
   <telerik:RadFormDecorator RenderMode="Lightweight" runat="server" ID="RadFormDecorator1" DecoratedControls="All" DecorationZoneID="zoneToDecorate" />
    <div class="demo-containers">
    <div class="demo-container" id="zoneToDecorate">
        <div>
            <p>
                <strong>                  
                    <asp:Label ID="ValidationSummary1Title" runat="server" />
                </strong>
            </p>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="SubmitInfo"
                EnableClientScript="False">
            </asp:ValidationSummary>
        </div>
        <p>
            <strong>Registration Form</strong>
        </p>
        <table>
            <tr>
                <td>
                    <table>
                        <tr>
                            <td>First Name:
                            </td>
                            <td>
                                <asp:TextBox ID="FirstBox" runat="server" Width="225px"></asp:TextBox>
                                *
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="FirstValidator" runat="server" ControlToValidate="FirstBox"
                                    EnableClientScript="false" ValidationGroup="SubmitInfo" ErrorMessage="Please fill in first name!"
                                    Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>Last Name:
                            </td>
                            <td>
                                <asp:TextBox ID="LastBox" runat="server" Width="225px"></asp:TextBox>
                                *
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="LastValidator" runat="server" ControlToValidate="LastBox"
                                    EnableClientScript="false" ValidationGroup="SubmitInfo" ErrorMessage="Please fill in last name!"
                                    Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>Skill Level:
                            </td>
                            <td>
                                <asp:DropDownList ID="ExperienceList" runat="server" Width="225px">
                                    <asp:ListItem Value="No Experience" Selected="True">No Experience</asp:ListItem>
                                    <asp:ListItem Value="Beginner">Beginner</asp:ListItem>
                                    <asp:ListItem Value="Good">Good</asp:ListItem>
                                    <asp:ListItem Value="Excellent">Excellent</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>Address:
                            </td>
                            <td>
                                <asp:TextBox ID="AddressBox" Width="225px" runat="server" TextMode="MultiLine" Columns="40"
                                    Rows="3"></asp:TextBox>
                                *
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="AddressValidator" runat="server" ControlToValidate="AddressBox"
                                    EnableClientScript="false" ValidationGroup="SubmitInfo" ErrorMessage="Please fill in your address!"
                                    Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td colspan="2">
                                <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ValidationGroup="SubmitInfo"
                                    ErrorMessage="The code you entered is not valid." Display="Dynamic" ForeColor="Red">
                                </telerik:RadCaptcha>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="150px" ValidationGroup="SubmitInfo"
                                    CausesValidation="true" OnClick="btnSubmit_Click" ></asp:Button>
                            </td>
                            <td></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    </div>

    <qsf:ConfiguratorPanel ID="ConfigurationPanel1" runat="server">
        <Views>
            <qsf:View>
                <qsf:ConfiguratorColumn runat="server" ID="ConfiguratorColumn1" Size="Medium">
                    <ul class="fb-group">
                        <li>
                            <asp:Label ID="lblErrorMessagePosition" Text="Choose Error Message Behavior:" runat="server" />
                            <qsf:DropDownList ID="ErrorMessagePosition" runat="server">
                                <Items>
                                    <telerik:DropDownListItem Text="None"></telerik:DropDownListItem>
                                    <telerik:DropDownListItem Text="Static"></telerik:DropDownListItem>
                                    <telerik:DropDownListItem Text="Dynamic" Selected="True"></telerik:DropDownListItem>
                                </Items>
                            </qsf:DropDownList>
                        </li>
                        <li>
                            <asp:CheckBox ID="CheckboxVG" runat="server" OnCheckedChanged="CheckboxVG_CheckedChanged"
                                Checked="true"></asp:CheckBox>
                            Set validation group of RadCaptcha
                        </li>
                        <li>
                            <qsf:Button ID="UpdateChanges" runat="server" Text="Update Changes"></qsf:Button>
                        </li>
                    </ul>
                </qsf:ConfiguratorColumn>
            </qsf:View>
        </Views>
    </qsf:ConfiguratorPanel>

    </form>
</body>
</html>

Support & Learning Resources

Find Assistance