Example E3633
Visible to All Users

ASP.NET Web Forms Editors - How to validate editors in a container on the server

This example demonstrates how to validate visible DevExpress Data Editors in a container.

Validate Editors in a Container

Pass a container to the ASPxEdit.ValidateEditorsInContainer method to validate visible editors in this container. To check whether all editors are valid, call the ASPxEdit.AreEditorsValid or ASPxClientEdit.AreEditorsValid method.

Files to Review

Documentation

More Examples

Example Code

WebSite/Default.aspx
ASPx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>How to validate editors in container </title> <script type="text/javascript" language="javascript"> function Validate(s, e) { if (ASPxClientEdit.ValidateGroup('testGroup')) ClientCallbackPanelDemo.PerformCallback(''); } </script> </head> <body> <form id="form1" runat="server"> <div> <dx:ASPxButton ID="ASPxButtonSave" runat="server" Text="Validate" AutoPostBack="False"> <ClientSideEvents Click="Validate" /> </dx:ASPxButton> <br /> <dx:ASPxCallbackPanel ID="ASPxCallbackPanelDemo" runat="server" HideContentOnCallback="False" ClientInstanceName="ClientCallbackPanelDemo" OnCallback="ASPxCallbackPanelDemo_Callback"> <PanelCollection> <dx:PanelContent ID="PanelContent1" runat="server"> <table cellspacing="0" cellpadding="4" runat="server" id="serverContainer"> <tr> <td style="width: 60px;"> <dx:ASPxLabel runat="server" ID="NameLabel" AssociatedControlID="txtNum1" Text="Number 1:" /> </td> <td> <dx:ASPxTextBox ID="txtNum1" runat="server" Width="170px" OnValidation="ASPxTextBoxTest_Validation"> <ValidationSettings ValidationGroup="testGroup"> <RequiredField IsRequired="True" ErrorText="Number 1 is required" /> </ValidationSettings> </dx:ASPxTextBox> </td> </tr> <tr> <td style="width: 60px;"> <dx:ASPxLabel runat="server" ID="ASPxLabel1" AssociatedControlID="txtNum2" Text="Number 2:" /> </td> <td> <dx:ASPxTextBox ID="txtNum2" runat="server" Width="170px" OnValidation="ASPxTextBoxTest_Validation"> <ValidationSettings ValidationGroup="testGroup"> <RequiredField IsRequired="True" ErrorText="Number 2 is required"/> </ValidationSettings> </dx:ASPxTextBox> </td> </tr> </table> </dx:PanelContent> </PanelCollection> </dx:ASPxCallbackPanel> </div> </form> </body> </html>
WebSite/Default.aspx.cs(vb)
C#
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using DevExpress.Web; public partial class _Default : System.Web.UI.Page { protected void Page_Init (object sender, EventArgs e) { } protected void ASPxCallbackPanelDemo_Callback (object sender, DevExpress.Web.CallbackEventArgsBase e) { ASPxCallbackPanel callbackPanel = (ASPxCallbackPanel)sender; bool isValid = ASPxEdit.ValidateEditorsInContainer(callbackPanel); } protected void ASPxTextBoxTest_Validation (object sender, ValidationEventArgs e) { ASPxTextBox txt = sender as ASPxTextBox; int val; bool result = Int32.TryParse(txt.Text, out val); e.IsValid = result; e.ErrorText = "An input value should be a number"; } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.