You create a Web Form. The Web Form contains a text box that has the ID txtName. The Web Form also contains a button named btnSave.
You need to use the RequiredFieldValidator control to ensure that the text box contains a value before it is submitted to the server.
What should you do?
A) Set the RequiredFieldValidator control's ControlToValidate property to txtName.
B) Set the RequiredFieldValidator control's InitialValue property to txtName.Text.
C) Set the RequiredFieldValidator control's EnableClientScript property to False. Add code to the form's btnSave_Click event that checks whether the text box contains a value. If it does not, set the RequiredFieldValidator's IsValid property to False.
D) Set the text box's CausesValidation property to True. Set its ValidationGroup to the ID of the RequiredFieldValidator control.
A - obvious answer, the ControlToValidate tells what control it will be checking to see if a value exist.
B - Wrong, sets the inital value to what is in the textbox.
C - kinda wrong, since you are setting the EnableClientScript to false, it would only check during the postback event that is thrown from the button. It might show you that the field is required or not only during postback though.
D - kinda wrong, this is better used on webcontrols that are not easily validated like a set of radio buttons.