|
-
May 5th, 2006, 11:26 AM
#1
Thread Starter
Junior Member
[2.0] Validating Text boxes
I am working on a Windows application in C#
I have two text boxes, to be validated with (txtFirstName and txtLastName)
Please could someone give me the syntax to use txtFirstName_Validating()
TO achieve the validation.
I have put the validation code inside the Button click event.
Please could you give me the best approach to validate the text boxes.
Thank you,
-----------------------------------------------------------------------
private void txtFirstName_Validating(object sender, CancelEventArgs e)
{
if (string.IsNullOrEmpty(txtFirstName.Text))
{
MessageBox.Show("First Name required!");
}
}
private void btnLookUp_Click(object sender, EventArgs e)
{
if ((txtFirstName.Text == string.Empty) || (txtLastName.Text ==
string.Empty))
{
MessageBox.Show("Please enter the Name..");
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|