I have a required field validator that i set to validate a textbox. Even when the text box is empty the accept button code still executes.. is this suppost to happen?
Printable View
I have a required field validator that i set to validate a textbox. Even when the text box is empty the accept button code still executes.. is this suppost to happen?
In the button_Click event, add this:
Code:If Page.IsValid Then
'whatever code you have here
End If
also, if you put a <asp:ValidationSummary> on the page then it should also be able to stop it with Javascript on the client side... but good practice is to also do what timeshifter has pointed out and use the Page.IsValid to also get it validated on the server side.