Runtime RequiredFieldValidator in ASP.net

Hello Friends, I hope you are doing well after such a long occasional and trdadional festive season. Here I want to share one important point which we miss sometime while using Required Field Validator. If some time we require validator to work on conditon base then we can apply the below method: Declare your control as DropDownList bind with RequiredFieldValidaor name as myReqVal and set Initial Value to 0 now write down the code on condtion where you want to active your RequiredFieldValidator .aspx.cs page myReqVal.Enabled = false; //If not required myReqVal.Enabled = true; //If required

Comments