Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Captcha / ValidationSummary


Validation Summary

Registration Form

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


Example Configuration
Choose Error Message Behavior:
select
Set validation group of RadCaptcha



  • Telerik RadCaptcha with ASP.NET ValidationSummary


    The example above demonstrates how to use the RadCaptcha with a ValidationSummary. 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, is 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.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Captcha.ValidationSummary.DefaultCS"
        CodeFile="DefaultCS.aspx.cs" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
    </head>
    <body class="BODY">
        <form id="Form2" method="post" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" ShowSkinChooser="false" />
        <telerik:RadScriptManager ID="ScriptManager" runat="server" />
        <telerik:RadFormDecorator ID="FormDecorator1" runat="server" ControlsToSkip="ValidationSummary" DecoratedControls="all">
        </telerik:RadFormDecorator>
        <br />
        <div>
            <fieldset style="width: 450px; height: 100px; margin-bottom: 10px;">
                <legend>Validation Summary</legend>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="SubmitInfo"
    EnableClientScript="False" />

            </fieldset>
        </div>
        <br />
        <b>Registration Form</b><br />
        <br />
        <table>
            <tr>
                <td style="vertical-align: top;">
                    <table>
                        <tr>
                            <td style="white-space: nowrap;">
                                First Name:
                            </td>
                            <td>
                                <asp:TextBox ID="FirstBox" runat="server"></asp:TextBox>
                                *
                            </td>
                            <td style="width: 300px;">
    <asp:RequiredFieldValidator ID="FirstValidator" runat="server" ControlToValidate="FirstBox"
    EnableClientScript="false" ValidationGroup="SubmitInfo" ErrorMessage="Please fill in first name!"
    Display="Dynamic"></asp:RequiredFieldValidator>

                            </td>
                        </tr>
                        <tr>
                            <td style="white-space: nowrap;">
                                Last Name:
                            </td>
                            <td>
                                <asp:TextBox ID="LastBox" runat="server"></asp:TextBox>
                                *
                            </td>
                            <td>
    <asp:RequiredFieldValidator ID="LastValidator" runat="server" ControlToValidate="LastBox"
    EnableClientScript="false" ValidationGroup="SubmitInfo" ErrorMessage="Please fill in last name!"
    Display="Dynamic"></asp:RequiredFieldValidator>

                            </td>
                        </tr>
                        <tr>
                            <td style="white-space: nowrap;">
                                Skill Level:
                            </td>
                            <td>
                                <asp:DropDownList ID="ExperienceList" runat="server">
                                    <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 style="white-space: nowrap;">
                                Address:
                            </td>
                            <td style="white-space: nowrap;">
    <asp:TextBox ID="AddressBox" Width="254px" 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"></asp:RequiredFieldValidator>

                            </td>
                        </tr>
                    </table>
                    <div>
                        <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ValidationGroup="SubmitInfo"
                            ErrorMessage="The code you entered is not valid." Display="Dynamic">
                        </telerik:RadCaptcha>
                    </div>
                    <br />
                    <div style="margin: 10px 0 0 0;">
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="150px" ValidationGroup="SubmitInfo"
    CausesValidation="true" />

                    </div>
                </td>
                <td style="padding: 0 60px 0 0; vertical-align: top; width: 300px;">
                    <qsf:ConfiguratorPanel ID="ConfigurationPanel1" runat="server" Orientation="Vertical"
                        Expanded="true">
                        <div style="margin-bottom: 5px; margin-top: 10px;">
                            Choose Error Message Behavior:
                        </div>
                        <div style="margin-bottom: 20px;">
                            <telerik:RadComboBox ID="ErrorMessagePosition" runat="server" OnSelectedIndexChanged="ErrorMessagePosition_SelectedIndexChanged">
                                <Items>
                                    <telerik:RadComboBoxItem Text="None" />
                                    <telerik:RadComboBoxItem Text="Static" />
                                    <telerik:RadComboBoxItem Text="Dynamic" Selected="True" />
                                </Items>
                            </telerik:RadComboBox>
                        </div>
                        <div>
    <asp:CheckBox ID="CheckboxVG" runat="server" OnCheckedChanged="CheckboxVG_CheckedChanged"
    Checked="true" />

                            Set validation group of RadCaptcha</div>
                        <br />
                        <br />
                        <div style="margin-bottom: 10px">
                            <asp:Button ID="UpdateChanges" runat="server" Text="Update Changes" />
                        </div>
                    </qsf:ConfiguratorPanel>
                </td>
            </tr>
        </table>
        <qsf:Footer runat="server" ID="Footer1" ShowCodeViewer="true" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451