Here one Error Provider Control can be used for multiple fields. Using this control, you can attach error messages that display next to the. MessageBox.Show( “Data Successfully Added”) ĮrrorProvider1.SetError(txtname, “Text Missing”) ĮrrorProvider1.Clear() // Clear all Error MessagesĮrrorProvider1.SetError(txtage, “Enter Valid Age”) ĭouble j = Convert.ToDouble(txtsalary.Text) ĮrrorProvider1.SetError(txtsalary, “Enter Valid Salary”) The ErrorProvider control is used to indicate invalid data on a data entry form. Private void ADD_Click( object sender, EventArgs e) ErrorProvider presents a simple mechanism for indicating to the end user that a control on a form has an error associated with it. An error that happened in an editor does not automatically clear itself on the editor’s value validation (when users leave the editor). When users hover over the icon, a tooltip displays the specified error text. An error appears as a ErrorType.Default error icon next to the editor where it occurred. In ADD button click you need to write the following code. For other controls, the method does nothing. Private Sub buttonSaveClick(ByVal sender As Object, ByVal e As System.EventArgs) Checks for a bad post code. But in Case of C# windows application this feature is not available so we use Error Provider control to do any type of validation. Since the ErrorProvider control does not have a visible component, it does not need to be added to the form. In ASP.Net 2.0 we use different Validation controls from Toolbox for validations (Just Drag & Drop, No need of writing code in C#).
0 Comments
Leave a Reply. |