What is the best way to display an error message when validating user input?
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
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
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
best, Display, error, input, message, user, Validating