Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to show any type of message using MessageBox in Windows Server 2008 R2 with ASP.NET using C#.

I use bellow this code:

MessageBox.Show("Registration Successfully Completed", "Success!!", MessageBoxButtons.OK, MessageBoxIcon.Information);

But show error:(bellow):

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.


Please solve this problem.
Posted
Comments
[no name] 14-Jun-14 9:20am    
There is no "problem" to solve. Where do you think server side code is going to display a MessageBox? You need to use client side code.

if you need to show message box to client; you need to use one of client side programming like javascript.
Check this Answer[^]
and also you can use Ajax ModalPopup[^]
 
Share this answer
 
Hi prakashmondal, you cannot show a MessageBox in an ASP.NET environment because the result of ASPNET is HTML and Javascript. Imagine that you have a client that connect from Linux, Linux cannot install .NET Framework so the MessageBox's class doesn't exists there.

C#
string script = "alert('Registration Successfully Completed!');";
ScriptManager.RegisterStartupScript(this, GetType(), 
                      "ServerControlScript", script, true);


Hope it helps.
 
Share this answer
 
Hi!
VB
Christian Amado


I want to use MessageBox as my choice like that..............

C#
DialogResult DiaR = MessageBox.Show("Registration Successfully Completed.Want to register another student?", "Success!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (DiaR.ToString() == "Yes")
                {
                    ////some actions
                }
                else
                {
                    // some action.......
                }



Then How to use???
 
Share this answer
 
Quote:
Hi!
VB
Christian Amado


I want to use MessageBox as my choice like that..............

C#
DialogResult DiaR = MessageBox.Show("Registration Successfully Completed.Want to register another student?", "Success!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (DiaR.ToString() == "Yes")
                {
                    ////some actions
                }
                else
                {
                    // some action.......
                }



Then How to use???
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900