Adding RequiredFieldValidtors programmatically
-
I am creating a couple of textboxes and dropdownlists dynamically. I need to put RFV for all of them. Since the rfv id will be different for each control, how will I generate them and make them fire if the values are not entered by the user. I tried adding the following: RequiredFieldValidator rfv1 = new RequiredFieldValidator(); rfv1.ControlToValidate = fieldTextBox.Id; But this is not firing? ANy help in this regard please? Thanks,
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
-
I am creating a couple of textboxes and dropdownlists dynamically. I need to put RFV for all of them. Since the rfv id will be different for each control, how will I generate them and make them fire if the values are not entered by the user. I tried adding the following: RequiredFieldValidator rfv1 = new RequiredFieldValidator(); rfv1.ControlToValidate = fieldTextBox.Id; But this is not firing? ANy help in this regard please? Thanks,
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
meeram395 wrote:
RequiredFieldValidator rfv1 = new RequiredFieldValidator(); rfv1.ControlToValidate = fieldTextBox.Id; But this is not firing? ANy help in this regard please?
I have write this on Page_Load()
RequiredFieldValidator _re = new RequiredFieldValidator(); _re.ID = "test"; _re.ControlToValidate = txtRoll.ID; _re.ErrorMessage = "This is a error Message"; form1.Controls.Add(_re);
and working fine ;)cheers, Abhijit CodeProject MVP My Blog :Abhijit's World of .Net
-
I am creating a couple of textboxes and dropdownlists dynamically. I need to put RFV for all of them. Since the rfv id will be different for each control, how will I generate them and make them fire if the values are not entered by the user. I tried adding the following: RequiredFieldValidator rfv1 = new RequiredFieldValidator(); rfv1.ControlToValidate = fieldTextBox.Id; But this is not firing? ANy help in this regard please? Thanks,
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
give some error message for your required field Validator like rfv1.ErrorMessage ="Some Message"