Friday, July 30, 2010

.NET PROJECT DEPLOYMENT ISSUES

Error :
Showing a modal dialog box or form when the application is runing in userinteractive mode is not valid operation



Reasons For This Error :
1.In Web Applications, when you create a Modal Dialog Box using MsgBox or MessageBox, even it would of been shown, it would of been shown in your server, not on the clients computer.

I suggest you to use an ajax:ConfirmButton or ajax:ModalPopup or another Ajax Control spread over the web.

2.Remember that this code is running on the web server in a process that is not running as the currently logged on (to the server) user. Therefore the process will be running under its own Window Station, and will not be able to interact with the desktop in any way. Consequently, you cannot display a MessageBox on the server without setting the flags to indicate that you want to display it on the currently logged in user's Window Station (effectively the default desktop).

This causes the Error.

Solution :

Use ScriptManager Tag
instead of MessageBox.show

Example : ScriptManager.RegisterStartupScript tag


Another Solution :

Take a look at MessageBoxOptions Enumeration. You can specify ServiceNotification, or DefaultDesktopOnly options, for when you have no form.
Here is an example.
MessageBox.Show("Message", "Caption", MessageBoxButtons.OK, _

MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, _

MessageBoxOptions.ServiceNotification)

No comments:

Post a Comment