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

Validation Group

  • About us
    • Mission Statement
    • Strategic Plan
    • Executive Bios
    • Contact Us
  • Products
    • Automotive
    • Machinery
    • Software
    • Customer Goods
  • Contact Us
    • Europe
    • America

Log in to access sections

Example Login Form
sign in

You can assign a group name to a set of validators to ensure that validation occurs only for controls in the specified group. This enables you to have multiple separately-validated forms on a single page.

You can use the ValidationGroup property when you want to perform separate validation tasks on the same page. In this example, the group name is assigned to all the validator controls and the button that causes the validation.

By default, all validators are in the "" group (the default group) for backward compatibility.

The page also exposes the GetValidators("group") and Validate("group") methods. Page.IsValid reflects the validity of all controls (cumulative) that have called the Validate method.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="PanelBar.Examples.Functionality.ValidationGroup.DefaultCS" %>

<%@ 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>
    <link rel="stylesheet" href="styles.css" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container no-bg" id="qsfexWrapper">
        <div id="qsfexLogo">
        </div>
        <div id="qsfexSearchBar">
            <asp:TextBox runat="server" ID="qsfexSearchBox" ValidationGroup="SearchValidationGroup"></asp:TextBox>
            <asp:RequiredFieldValidator runat="server" CssClass="qsfexErrorMessage" ID="RequiredFieldValidator1"
                ControlToValidate="qsfexSearchBox" Display="Dynamic" ErrorMessage="Please enter a search term!"
                ValidationGroup="SearchValidationGroup"></asp:RequiredFieldValidator>
            <asp:LinkButton ID="LinkButton1" runat="server" CssClass="qsfexSearch" CausesValidation="true"
                ValidationGroup="SearchValidationGroup"></asp:LinkButton>
        </div>
        <div>
            <div style="padding-top: 110px">
                <telerik:RadPanelBar RenderMode="Lightweight" ID="RadPanelBar1" runat="server" ValidationGroup="LoginValidationGroup"
                    CausesValidation="true" Height="258px" Width="200px" ExpandMode="FullExpandedItem"
                    OnItemClick="RadPanelBar1_ItemClick" Skin="Black">
                    <Items>
                        <telerik:RadPanelItem Text="About us" runat="server" Expanded="True">
                            <Items>
                                <telerik:RadPanelItem Text="Mission Statement" runat="server">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Strategic Plan" runat="server">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Executive Bios" runat="server">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Contact Us" runat="server">
                                </telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelItem>
                        <telerik:RadPanelItem Text="Products" runat="server">
                            <Items>
                                <telerik:RadPanelItem Text="Automotive" runat="server">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Machinery" runat="server">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Software" runat="server">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Customer Goods" runat="server">
                                </telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelItem>
                        <telerik:RadPanelItem Text="Contact Us" runat="server">
                            <Items>
                                <telerik:RadPanelItem Text="Europe" runat="server">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="America" runat="server">
                                </telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelItem>
                    </Items>
                </telerik:RadPanelBar>
            </div>
            <div id="qsfexLoginPanel" style="margin-left: 200px">
                <p id="qsfexLoginMessage">
                    Log in to access sections</p>
                <div id="qsfexDecoration" style="color: red">
                </div>
                <fieldset>
                    <legend>Example Login Form</legend>
                    <div class="qsfexFieldWrapper">
                        <asp:Label ID="Label1" runat="server" AssociatedControlID="qsfexUsername">Username</asp:Label>
                        <asp:TextBox runat="server" ID="qsfexUsername"></asp:TextBox>
                        <asp:RequiredFieldValidator runat="server" CssClass="qsfexErrorMessage" ID="qsfexRequiredFieldValidator1"
                            ControlToValidate="qsfexUsername" Display="Dynamic" ErrorMessage="Please Fill in Username and Password to see section!"
                            ValidationGroup="LoginValidationGroup"></asp:RequiredFieldValidator>
                    </div>
                    <div class="qsfexFieldWrapper">
                        <asp:Label ID="Label2" runat="server" AssociatedControlID="qsfexPassword">Password</asp:Label>
                        <asp:TextBox runat="server" TextMode="password" ID="qsfexPassword"></asp:TextBox>
                        <asp:RequiredFieldValidator runat="server" CssClass="qsfexErrorMessage" ID="qsfexRequiredFieldValidator2"
                            ControlToValidate="qsfexPassword" Display="Dynamic" ErrorMessage="Please Fill in Username and Password to see section!"
                            ValidationGroup="LoginValidationGroup"></asp:RequiredFieldValidator>
                    </div>
                    <asp:LinkButton ID="LinkButton2" CausesValidation="true" ValidationGroup="LoginValidationGroup"
                        runat="server" Text="sign in" CssClass="qsfexSignIn"></asp:LinkButton>
                </fieldset>
            </div>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance