开发者

How can I extend ASP.NET server-side validation controls to raise an event if validation fails?

I am using ASP.NET's server-side validation. In the page_load event I'm calling Page.Validate(), and if Page.IsValid is not true I'm then polling the controls to figure out which ones are not valid, and then determining what actions to take.

It would be much easier if each control would raise an event as validation开发者_StackOverflow fails, allowing me to take action for that particular control. I'm very much a naive programmer when it comes to validation, but is there a way to extend these controls so that a validation error raises an event?


In order to do this, you would have to write your own subclass of each of the validators you want to use.

I haven't looked at the code for these validators in a long time, so I wouldn't be able to tell you if there were any issues in doing this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜