开发者

Using ASP.NET validators on multiple controls

开发者 https://www.devze.com 2023-01-13 02:30 出处:网络
can we use the same validator of a control for two different buttons, or do we need to write add a valida开发者_JAVA技巧tor for each control for two different buttons.Each ASP.NET validator control ca

can we use the same validator of a control for two different buttons, or do we need to write add a valida开发者_JAVA技巧tor for each control for two different buttons.


Each ASP.NET validator control can be bound to exactly one ControlToValidate, except for the CompareValidator. The CompareValidator also has a ControlToCompare property. You need to add a validator for each control you wish to validate.

When you find that your markup gets bloated with validators, you can also create a handy extension methods on Control and let it automaticaly add a new validator to the page. You can invoke this method in your code behind in OnPreInit or OnInit.

0

精彩评论

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