Form Concepts - Windows Forms MessageBox

From Visual WebGui Wiki

Jump to: navigation, search

Overview

A common mistake in Visual WebGui programming is forgetting to import (import in VB.NET, using in C#) Gizmox.WebGui.Forms in your code before you use MessageBox. In that case it is not uncommon that instead of calling Gizmox.WebGui.Forms.MessageBox, you are actually calling System.Windows.Forms.MessageBox.

The same situation is obtained by using VB.NET's MsgBox or InputBox dialogs.

What happens when these are used

In that case the server will try to show a MessageBox, but will have two problems with it:

  • The server will try to show it on the server itself, as Windows Forms will show the MessageBox (or MsgBox or InputBox) within the same thread that is initiating it.
  • The server is running under a non UI (User Interface) thread (The web server) so there will be no messagebox shown.

The same applies to any class that derives from Form (or any other class for that matter)... if you don't make sure it inherits from Gizmox.WebGui.Forms, you have the same potential problem.

But it works in Visual Studio Development environment

In the Visual Studio development environment, you have the server side (code behind) code running under Visual Studio, which has an UI attached, so when you run your application in that environment it does indeed seem to be working. You will see soon enough after you deploy that it is not the case.

Personal tools