Business and Technology Consulting Organization in Mumbai

Electronic Transformation Globally Technology Solution IT Consultancy Service Provider

Asp.net Validation controls

The BaseValidator class defines the basic implementation needed for all Validation controls. There are 6 Validation Controls included in the ASP.NET 2.0 and ASP.NET 3.5 framework which validate controls to prevent the users from entering wrong data


 
CustomVaidator example in asp.net
Step 1 :
write a javascript function with all validation you want to perform:
< script language="javascript" type="text/javascript" >
function IsValidBetAmount(sender, args) {
// alert(args.Value);
var betValue = eval(args.Value);
if (betValue % 1000 == 0) {
args.IsValid = true;
return
}
else
args.IsValid = false;
}
< /script >

Step 2 :
Set a control and a custom validator to perform the test
< asp:TextBox runat="server" ID="txtBetAmount" CssClass="txtBox" ValidationGroup="vgBetAmount" >< /asp:TextBox >
< asp:CustomValidator runat="server" ID="cvBetAmount" ControlToValidate="txtBetAmount" ValidationGroup="vgBetAmount" ClientValidationFunction="IsValidBetAmount" ErrorMessage="Bet should be round of 1000." ValidateEmptyText="true" / >

Step 3 :
Set a action button where you need to perfom the validation
< asp:Button runat="server" ID="btnSubmitBet" Text="Bet" CssClass="button" ValidationGroup="vgBetAmount" OnClick="btnSubmitBet_Click" / >
Leave your comment.

Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession

Advertisement
Sponsored by

HR Recruitment & Process Management System
Jewellery production process management software
Share
©2009 ETG Consultancy, All Rights Reserved Privacy Policy | Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML