.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
satyapriyanayak
Sambanthamoorthy

Home >> Code Snippets >> Validations >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Validations in DevExpress controls

Posted By:Deepika Haridas       Posted Date: October 27, 2010    Points: 15    Category: Validations    URL: http://www.angeldeeps.blogspot.com  

This code shows usage of validations in Devexpress controls.
 

This code shows usage of validations in Devexpress controls.

Note : I have tested this using version 9.2.3 and 9.3.2

ASPX Page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ValidationsDev.aspx.cs" Inherits="ValidationsDev" %>

<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.2, Version=9.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.2, Version=9.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxg" %>
    <%@ Register Assembly="DevExpress.Web.v9.2, Version=9.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dxtc" %>

    <%@ Register Assembly="DevExpress.Web.v9.2, Version=9.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dxp" %>
<%@ Register Assembly="DevExpress.Web.v9.2, Version=9.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dxrp" %> 



    Validations

    



    
    
<%--Textbox validation example--%> <%--Combo box example--%>
<%--Get multiple values in combobox--%> <%--Get selected values in listbox --%> <%--Gridview on dropdown click--%>

Code behind page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ValidationsDev : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void txtSample_Validation(object sender, DevExpress.Web.ASPxEditors.ValidationEventArgs e)
    {
        if ((e.Value as string).Length < 2)
            e.IsValid = false;
    }
    protected void txtAge_Validation(object sender, DevExpress.Web.ASPxEditors.ValidationEventArgs e)
    {       
        string strAge = ((string)e.Value).TrimStart('0');
        if (strAge.Length == 0)
            return;
        UInt32 age = 0;
        if (!UInt32.TryParse(strAge, out age) || age < 18)
            e.IsValid = false;
    }
}



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend