Skip to main content

Posts

Showing posts with the label Validations controls in server side

How to change control's background color when validation fails when controls have multiple validation

 Here Is the Code sample :   using System ; using System . Collections . Generic ; using System . Linq ; using System . Web ; using System . Web . UI ; using System . Web . UI . WebControls ; namespace ValidationHelper { public class ValidationBGColorAdjustor { public static void SetBGColor ( Page page ) { Dictionary < string , List > controls = new Dictionary < string , List >(); foreach ( BaseValidator validator in page . Validators ) { if ( controls . ContainsKey ( validator . ControlToValidate )) controls [ validator . ControlToValidate ]. Add ( validator . IsValid ); else controls [ validator . ControlToValidate ] = new List () { validator . IsValid }; } foreach ( string s in controls . Keys ) { bool IsValid = true ; ...