Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

required field validator in .net1.1

hi
i have a web form,in which user can select a radiobutton and few controls will be visible on the form. i have 3 such radio buttons and have used validators for diffent controls.now if user is selecting first radi button and submiting without text,required field validator is showing error but when user selects another radio button and submitting the form,required field validator which belongs to the first radio button is showing error.
how to fix this?
using .net1.1/c#
thank you
0
tag_k
Asked:
tag_k
  • 2
  • 2
1 Solution
 
Fernando SotoRetiredCommented:
Hi tag_k;

You state that, "if user is selecting first radi button and submiting without text,required field validator is showing error ", What is the ControlToValidate property of the RequiredFieldValidatator set to. It can not be set to a radio button.

Fernando
0
 
tag_kAuthor Commented:
Hi Fernando,
Control to validate is set to textbox which is made visible when radiobutton1 is selected.
when user tries to subit form without any text in textbox for the first time,its showing error which is good.but when user submitts the form again and again without text in textboxes,then problem is raised.
it shows error message for the controls which are not visible on the form at that moment(i.e controls under radio button 2 and 3).
0
 
tag_kAuthor Commented:
i even have controls(textboxes and buttons) under radiobutton 2 and 3,these textboxes have required field valdator.
ex:
i have 2 radio buttons add and delete.
when i select add,2 controls appear on the form.textbox1 and button1.i hit button1 without any text in textbox1,its shows required field validator.now i select delete radiobutton,textbox2 and button2 are visible on form and i hit button with out text in textbox,it shows required field.

but when again i select radiobutton 1 and hit button1 without text in textbox1,i see 2required field error messages(one from textbox1,which is visble on form and second from textbox2 ,which is not visible on form).
0
 
Fernando SotoRetiredCommented:
Hi tag_k;

This is what is happening. Because you hide or make Visible property to false does not mean that the RequiredFieldValidayor stops working. When you make the TextBox Visiable property to false you need to make the RequiredFieldValidator.Enabled = false so that it will not validate a inactive control.

Fernando
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now