Search KB Filter article types
ErrorProvider CodeSample - Errorchecking whole form on a button click
Categories: Status & Indication
Tags: Developers, Windows & Dialogs, 1. Beginner, Navigation, Pre v6.3, v6.3, v6.4 and Later, 2. Intermediate, 3. Advanced
Revision: 1
Posted: 20/Sep/2009
Updated: 23/July/2010
Status: Publish
Types: Article

This article will have a few sections added to it soon, based on the following article type skeleton: CodeSample
Overview

This is just a very simple sample on how to use the control. Attaching the error checking to the validation of each textbox control is what is usually prefered as opposed to this case which provides a Button to error check the whole form at the same time. Attaching those error checking to the validation events gives the user more feeling of "online" error checking.

VB.NET Code
Imports Gizmox.WebGui.Forms
Public Class Form1
 
    Friend WithEvents TextBox1 As Gizmox.WebGui.Forms.TextBox
    Friend WithEvents EP As Gizmox.WebGui.Forms.ErrorProvider
    Friend WithEvents TextBox2 As Gizmox.WebGui.Forms.TextBox
    Friend WithEvents btnSaveButton As Gizmox.WebGui.Forms.Button
 
 
 
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.TextBox1 = New Gizmox.WebGui.Forms.TextBox
        Me.EP = New Gizmox.WebGui.Forms.ErrorProvider(Me.components)
        Me.TextBox2 = New Gizmox.WebGui.Forms.TextBox
        Me.btnSaveButton = New Gizmox.WebGui.Forms.Button
 
        Me.TextBox1.Location = New System.Drawing.Point(12, 27)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(100, 20)
        Me.TextBox1.TabIndex = 0
 
        Me.EP.BlinkRate = 3
        Me.EP.BlinkStyle = Gizmox.WebGui.Forms.ErrorBlinkStyle.BlinkIfDifferentError
        Me.EP.DataMember = ""
        Me.EP.DataSource = ""
        Me.EP.Icon = Nothing
 
        Me.TextBox2.Location = New System.Drawing.Point(151, 27)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(100, 20)
        Me.TextBox2.TabIndex = 1
 
        Me.btnSaveButton.Location = New System.Drawing.Point(273, 24)
        Me.btnSaveButton.Name = "btnSaveButton"
        Me.btnSaveButton.Size = New System.Drawing.Size(75, 23)
        Me.btnSaveButton.TabIndex = 2
        Me.btnSaveButton.Text = "Save"
        AddHandler btnSaveButton.Click, AddressOf btnSaveButton_Click
 
        Me.Controls.Add(Me.btnSaveButton)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
    End Sub
 
 
 
 
    Private Sub btnSaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If AreWeErrorFree() Then
            MessageBox.Show("We are error free!")
        Else
            MessageBox.Show("We have some errors!")
        End If
    End Sub
 
 
 
 
    Private Function AreWeErrorFree() As Boolean
        EP.SetError(TextBox1, "")
        EP.SetError(TextBox2, "")
        If TextBox1.Text = "" Then
            EP.SetError(TextBox1, "You must enter text")
        End If
        If TextBox2.Text = "" Then
            EP.SetError(TextBox2, "You must enter text")
        End If
        Return EP.GetError(TextBox1) = "" And EP.GetError(TextBox2) = ""
    End Function
 
End Class

C# Code
The conversion of this code to C# has not been completed yet.

About the author

Related Articles

Status & Indication  
Title Update Author
This video demonstrates how to use the error provider
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
01/Jan/2009    2009/01/01
This video demonstrates how to use the error provider in Visual WebGui.
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
11/Jan/2007    2007/01/11
Tags: Developers, Data Binding, Events, 1. Beginner, 2. Intermediate, Integration, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
05/Jan/2009    2009/01/05
This application demonstrates how to use the Timer to update a TextBox and a ProgressBar control.
Tags: Developers, Events, 1. Beginner, Pre v6.3, v6.3, v6.4 and Later, 2. Intermediate, 3. Advanced
12/Jan/2009    2009/01/12
This article demonstrates the use of an active Gauge in a Visual WebGui application.
Tags: Developers, 1. Beginner, 2. Intermediate, 3. Advanced, v6.3, v6.4 and Later
12/Jan/2009    2009/01/12
Tags: Architects, Developers, 2. Intermediate, 3. Advanced, Customization, Optimizing Performance, v6.4 and Later
12/Jan/2009    2009/01/12
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS