What is the best way to display an error message when validating user input?

Hi Everyone,

Do any of you know how to best display en error message when validating user input (Server-side). I know that you can use a message box when working on the client-side, but it doesn’t work when sending data to server.

I understand that I have to use PostBack, but how do you display an error message when a user does not select or enter:

1. A product from a drop down list – Select the Product Name or
2. A value into a text box (Integer) – Select Number of Units

Can the same function be used in both instances or do you have 2 different functions for each.

For example:
The user presses Calculate before selecting a Product or fails to input the number of units

Please see the code and image below:

Code for PostBack

Code:

        Dim SuccessMessage As String

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

                If Page.IsPostBack = False Then

                        ResultTextBox.Text = ""
                        NoOfUnitsTextBox.Text = ""

                End If

                'If Page.IsPostBack = True Then

                '        SuccessMessage = MsgBox("Product Submitted")

                'End If

        End Sub


Code for Calculate Button

Code:

        Private Sub CalculateLinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalculateLinkButton.Click

                numberOfUnits = Convert.ToInt32(NoOfUnitsTextBox.Text)
                ResultTextBox.Text = CalculateCubicMeters()

        End Sub


I would highly appreciate you guys’ valuable input. Thanks a million!

Pinkerton

View full post on Tycoon Talk

, , , , , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes


RSS Site FeedRSS Site Feed

© 1992-2011 DC2NET™, Inc. All Rights Reserved