Error: 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.
This error is occure due to message box.
Loading


Sanjay Chauhan55 reputationPosted Aug 10, 2009, 3:12 AM EDT
U can specify servicenotification or DefaultDesktopOnly option in message box enumeration .
Specify like that
MessageBoxOptions.ServiceNotification
MessageBoxOptions.DefaultDesktopOnly
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 10, 2009, 3:48 AM EDT
Hi, Using MsgBox is not intended to work in ASP.NET 2.0. If it works, it will show a message box on the server rather than on the client machine and if you try to Show it you will get error that is Wrritten by you in your Question ( This is what Microsoft Says ) :) You can Show Dialog box Like Below Code very Easily and Efficiently Dont Forget to Mark "Do you Like answer" it will give me some credits protected void Button4_Click(object sender, EventArgs e) { Page.RegisterClientScriptBlock("ShowMessage", "script>alert('Hello This is MessageBox')script>"); } Happy Coding :)Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Aug 10, 2009, 4:58 AM EDT
There is no direct solution, the use of a messagebox which is raised in server-side code is illogical in a client-server situation such as a browser based application. There are basically two options that you can consider:
1) Modify your approach to allow you to use client-side script to display alerts using window.alert() for example before posting back to the server once everything is sorted
2) Modify your approach to end the processing server-side, emit relevant client-side script and html to display the alert on the client, then handle the continuation of processing on the server side.
Personally I would go with option 1 as it is generally the easiest (though not always easy).
OF course there is a third option which is to use a different mechanism for recording alerts generated in this way (or just don't do it!).
If you want to display a message I would use...
Response.Write("")