开发者

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.


  1. You can do a Page.IsValid before trying to save to the database.

  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜