关于避免验证子页面控件 [英] About avoid validating of child pages controls

查看:68
本文介绍了关于避免验证子页面控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的专家

我有一个Windows应用程序,我在不同条件下将表单和用户控件驻留在母版页中
我的问题是,如果我单击母版页上的某些按钮,则不应执行子控件的验证
表示如果我验证文本框不允许在休假事件中允许空白,并且如果它为空白,那么即使我单击母版页按钮而该文本框为空白并且控件位于文本框中,也应该在不验证文本框的情况下单击它

Dear experts

I have one windows application and i am residing forms and user controls on different conditions in master page
My problem is that if i click some button on master page it should not execute validation of child control
Means if i validate textbox not to allow blank on leave event and if it is blank then even if i click master page button when that textbox is blank and control is in textbox it should get clicked without validating textbox

推荐答案

您不能:Validating事件总是在Click事件之前发生,因此您的验证处理程序无法知道焦点将在哪里结束以及下一步将发生什么.

您做这种事情的唯一方法是很混乱的:在Validating事件中设置一个计时器,然后在单击按钮时将其取消.如果计时器过去,则进行实际验证.讨厌的东西.作为用户,这可能会让我很烦,因为我经常使用TAB在字段之间移动,如果到达那里,我希望能够立即键入.

最好考虑对某些字段使用更高版本的验证-也许当用户单击确定"时?
You can''t: The Validating event always happens before the Click event, so your validating handler has no way to know where the focus will end up and what will happen next.

The only way you could do anything like that is very messy: set a timer in the Validating event, and cancel it in the button click. If the timer elapses then do the actual validation. Nasty stuff. As a User, that would probably annoy me, as I use TAB to move between fields a lot and if I get there, I expect to be able to type immediately.

It might be better to consider using later validation for some fields - when the user clicks "OK" perhaps?


这篇关于关于避免验证子页面控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆