简体   繁体   English

验证Button1单击,但不验证Button2

[英]Validate on Button1 click, but not Button2

I have two buttons, a text box, and a combo box on a page: 我在页面上有两个按钮,一个文本框和一个组合框:

The user inputs an integer to search for in the text box, and presses the Find button. 用户在文本框中输入要搜索的整数,然后按“查找”按钮。 A data grid is populated, the user selects a row, and clicks the Print button. 填充数据网格,用户选择一行,然后单击“打印”按钮。

I want the Print button to validate that a selection has been made in the combo box (ie selectedindex is not -1). 我希望使用“打印”按钮来验证是否已在组合框中进行了选择(即,selectedindex不是-1)。 The combo box is an ASPxComboBox (DevExpress control). 组合框是一个ASPxComboBox(DevExpress控件)。 On the ComboBox, RequiredField.IsRequired is set to True. 在ComboBox上,RequiredField.IsRequired设置为True。 However, this causes the ComboBox to be validated on click of both Find AND on Print. 但是,这会导致同时单击“查找”和“打印”时都验证ComboBox。 Validation should not happen on click of the Find button. 单击“查找”按钮不应进行验证。

How can I force a selection in my combobox on click of one button but not another? 单击一个按钮而不单击另一个按钮,如何在组合框中强制进行选择?

在不想触发验证的“查找”按钮上,设置属性

CausesValidation="false"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM