Hi,
I have a RadDropdownlist which should allow the user to type in only numeric values in it. Validations in Key_Down and Key_Press event does fire but it is not working. I have similar validations for normal textboxes and it is working.
Is there are any ways to restrict the user to type only numeric values in RadDropDown?
Thank you in advance for the help.
I have a RadDropdownlist which should allow the user to type in only numeric values in it. Validations in Key_Down and Key_Press event does fire but it is not working. I have similar validations for normal textboxes and it is working.
Is there are any ways to restrict the user to type only numeric values in RadDropDown?
private bool nonNumberEntered = false; protected void radDDLAccountNo_KeyDown(Object sender, KeyEventArgs e) { ValidateNumericField(e); } private void radDDLAccountNo_KeyPress(Object sender, KeyPressEventArgs e) { KeyPressEvent(e); }private void ValidateNumericField(KeyEventArgs e) { nonNumberEntered = false; if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9) { if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9) { if (e.KeyCode != Keys.Back) nonNumberEntered = true; } } if (Control.ModifierKeys == Keys.Shift) nonNumberEntered = true; } private void KeyPressEvent(KeyPressEventArgs e) { if (nonNumberEntered == true) { e.Handled = true; } } Thank you in advance for the help.
