Thanks. But just a sort of clarification, let's say what if a user had entered an invalid age in a textbox. And then a messagebox will pop up with a message "Sorry, your age is not qualified!". How can I do this?
if you use the dropdownlist and add the number in to it, then there is no question of user making the mistake and so no need to prompt too..
Visual Basic code
Private flag As Boolean
Private Sub MyTextChangedHandler(sender As System.Object, e As System.EventArgs)
' Check the flag to prevent code re-entry.
If flag = False Then
' Set the flag to True to prevent re-entry of the code below.
flag = True
' Determine if the text of the control is a number.
If IsNumeric(textBox1.Text) = False Then
' Display a message box and clear the contents if not a number.
MessageBox.Show("The text is not a valid number. Please re-enter")
' Clear the contents of the text box to allow re-entry.
' Reset the flag so other TextChanged events are processed correctly.
flag = False