Saturday, February 5, 2011

UI Field Validation in WPF

UI field validation in WPF is a one of most important. Because when the field can't get the Specific class then it will get Error. So it better to create a CheckField()  for specific Button Event & there you can implement the method as:

/******************* A Button Event *****************/
         private void appointAddButton_Click(object sender, RoutedEventArgs e)

     /************** Implement AddAppointmentInListView Method*****************/
        private void AddAppointmentInListView()
                if (CheckField())
                    EAppointment objAppointment = new EAppointment();
                    objAppointment.TrackNo = Convert.ToInt64(employeeTrackNoTextBox.Text);
                    objAppointment.InterviewId = Convert.ToInt64(employeeIdTextBox.Text);
                    objAppointment.AppointmentDate =  appointDateDateTimePicker.SelectedDate.Value;
                    List<EAppointment> listAppoint = new List<EAppointment>();
                    objAppointment.AppointList = listAppoint;
            catch (Exception e)
  /************* Implement CheckField Method************/
 /********* Note that you should Declare raiseKeyUp as Global********
/******** private bool raiseKeyUp = true; ********/
     private bool CheckField()
            if (employeeTrackNoTextBox.Text.Trim() == string.Empty)
                MessageBox.Show("Please enter Track Number", "IEMS", MessageBoxButton.OK);
                this.raiseKeyUp = false;
                return false;
                             return true;

  You can also Make your Validation Field more Glossy if you download the Code from the link:


  Now see what happen in your validation. Enjoy......!!

vfpoledeb.1 provider is not registered on the local machine

Have u Install VFP Ole DB Provider in your System ? If No then Please Install it from following link.