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

ComboBox / Validation Groups

Search Form
  • select
  • Search

  • Validation groups allow you to organize validation controls on a page as a set. Each validation group can perform validation independently from other validation groups on the page. You create a validation group by setting the ValidationGroup property to the same name (a string) for all the controls you want to group. You can assign any name to a validation group, but you must use the same name for all members of the group.

    There are two validation groups in this example:

    1. The "SearchFormValidationGroup" contains a RadTextBox and a RadComboBox which are validated by two RequiredFieldValidator controls. The ValidationGroup property of the validators and the "Search" button is set to SearchFormValidationGroup. Pressing the "Search" button will trigger validation only for the SearchFormValidationGroup.
    2. The "LoginFormValidationGroup" contains two RadTextBox controls which are validated by two RequiredFieldValidator controls. The ValidationGroup property of the validators and the "Login" button is set to LoginFormValidationGroup. Pressing the "Login" button will trigger validation only for the LoginFormValidationGroup.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Inherits="Telerik.ComboBoxExamplesCSharp.ValidationGroup.DefaultCS" Language="c#"
        CodeFile="DefaultCS.aspx.cs" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <!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 runat="server" ID="Headtag1" />
        <link rel="stylesheet" type="text/css" href="styles.css" />
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <qsf:Header runat="server" ID="Header1" NavigationLanguage="C#" />
            <div class="example-panel">
                <span class="video-title">Search Form</span>
                <ul class="video-form">
                    <li>
                        <label>
                            Find a video:</label>
                        <telerik:RadTextBox runat="server" ID="RadTextBox1" Width="180px" />
    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="RadTextBox1"
    ErrorMessage="Please enter a name" ValidationGroup="SearchFormValidationGroup"
    CssClass="validator" />

                    </li>
                    <li>
                        <label>
                            Search in:</label>
                        <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="180px"/>
    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="RadComboBox1"
    InitialValue="- Search in -" ErrorMessage="Please select a search location" ValidationGroup="SearchFormValidationGroup"
    CssClass="validator" />

                    </li>
                    <li>
    <asp:LinkButton runat="server" ID="Button1" Text="Search" ValidationGroup="SearchFormValidationGroup"
    CssClass="form-button" />

                    </li>
                </ul>
                <span class="login-title">Login Form</span>
                <ul class="login-form">
                    <li>
                        <label>
                            Username:</label>
                        <telerik:RadTextBox runat="server" ID="RadTextBox2" Width="172px" />
    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator4" ControlToValidate="RadTextBox2"
    ErrorMessage="Please enter a Username." ValidationGroup="LoginFormValidationGroup"
    CssClass="validator" />

                    </li>
                    <li>
                        <label>
                            Password:</label>
                        <telerik:RadTextBox runat="server" ID="RadTextBox3" Width="172px" />
    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator5" ControlToValidate="RadTextBox3"
    ErrorMessage="Please enter a Password" ValidationGroup="LoginFormValidationGroup"
    CssClass="validator" />

                    </li>
                    <li>
    <asp:LinkButton ID="Button2" runat="server" Text="Login" ValidationGroup="LoginFormValidationGroup"
    CssClass="form-button" />

                    </li>
                </ul>
            </div>
            <qsf:Footer runat="server" ID="Footer1" />
        </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