Skip to main content

Posts

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 ; ...

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

Here is the java script : function ContainsControl ( controlArray , arrayItem ) { var result = { boolValue : false , indexValue : - 1 }; for ( var i = 0 ; i < controlArray . length ; i ++) { if ( controlArray [ i ][ "control" ] == arrayItem . control ) { result . boolValue = true ; result . indexValue = i ; break ; } } return result ; } function SetBGColor () { var inputControlValidationResult = new Array (); for ( var i = 0 ; i < Page_Validators . length ; i ++) { var inputControl = document . getElementById ( Page_Validators [ i ]. controltovalidate ); var arrayItem = { control : inputControl , valid : Page_Validators [ i ]. isvalid ? 1 : 0 }; var result = ContainsControl ( inputControlValidationResult , arrayItem ); if ( result . boolValue ) { inputControlValidationResult [ re...

Send E-mail with attached file in asp.net

First of all add one namespace using System.Net.Mail then enter following code . make sure that following code has attached one text file with folder name you have to give you folder name and file name. "); strbody.Append(" "); string result = SendEMailMessage( "test@gmail.com" ,  "test" ,  "test1@gmail.com" , strbody.ToString(),  "Testing" ); if (result.ToString() ==  "Mail sent successfully" )        ScriptManager.RegisterStartupScript(Page, Page.GetType(),  "str" ,  "alert('Mail Sent Successfully.');" , true); else        ScriptManager.RegisterStartupScript(Page, Page.GetType(),  "str" ,  "alert('Mail Sending fail.');" , true); public static string SendEMailAttachment(string EMailFrom, string EMailName, string EMailTo, string EmailBody, string EmailSubject)      {         ...