Use a RequiredFieldValidator in my webform
I used a requiredfieldvalidator in my webform application. I want when a person fills all of textboxes in my form and then press "OK" button, the data save to database. But if any textboxes didn't fill, requiredfieldvalidator show a message a开发者_如何学运维nd data doesn't save to database. Now I can use requiredfieldvalidator and it messages me when textboxes didn't fill. But other data in my textboxes will save to my database. Please help me that in this condition, the data doesn't save to database. Thanks.
Validate your data on the server side (e.g. on the button click) before committing data to the database. Remember that if, for example, the user has disabled javascript in the browser, the validators will not work.
On the client side, you can use the ValidationGroup property.
You can do a Page.IsValid before trying to save to the database.
If you have used Validation Groups, make sure that you have properly used the validation groups for all the components.
It would be better to see some code though.
精彩评论