开发者

Web User Control validation doesn't stop page events

This is a weird problem. I have created Web User Control with two TextBoxes and two CustomValidators (server-side only). I have also implemented IValidator interface and created ValidationGroup property that deafults to null.

The problem is that when I put this control on a website it doesn't block events when it's not valid. I've set CausesValidation on a Button that just reads proerty of my Web User Control a开发者_C百科nd writes it to Label.

Any ideas why Button OnCLick event fires ALWAYS?


Validators don't prevent the normal course of the asp.net lifecycle of a page. In your handler, you should check Page.IsValid and not do any of your normal processing if Page.IsValid = false

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜