Error Message Customization

Use RegisterJScriptAlert to Display Messages

Code Customization
Use RegisterJScriptAlert to Display Messages
Description:

In Microsoft Windows applications you can call MessageBox to display a message to the user. Unfortunately, there is no equivalent in web applications when you are executing server-side code. For example, if you write a validation routine, you cannot simply call MessageBox to display an error message to the user.

If you want to give an error message to the user, you can use the standard .ErrorMessage property to set the value that will be displayed to the user. In some cases, you might want to have your own custom function. So how can we do this?

In Microsoft .NET applications, data validation occurs in a postback. When the page is first loaded, the data is displayed, and when you press the Submit button, a postback is triggered and your server-side code is called to validate the data. This postback will eventually either re-display this page or redirect to another page.

If you want to display an error message, you need to do two things. First, register the alert message, and second, cancel any redirection. Registering the alert message ensures that when the page is re-displayed as part of the postback, any registered messages will be displayed to the user. If you do not cancel the redirection to another page, your registered alert message will never be displayed.

This example adds code to display alert message when a button is clicked. It makes use of RegisterJScriptAlert() method to register and display the alert message.

Procedure:

Step 1:  In Iron Speed Designer, switch to Layout Editor then select a panel.

Step 2:  Drag and drop a Button (Themed) from the Toolbox to a desired cell.

Step 3:  Display the Properties dialog for the button. Go to the Display tab and set the Button text.

Step 4:  Build your application.

Step 5:  Use this wizard to add code customization.

Step 6:  Build and run the application.

Disclaimer:
Customizations included in this wizard are provided as a sample to demonstrate a feature, and may work only in specific situations. The Iron Speed Designer support team cannot assist in the resolution of problems which may occur as a result of customizing your application or modifying a customization to fit a particular purpose.

Terms of Service Privacy Statement