MessageBox in C# - errors

  • Thread starter Thread starter Zeba
  • Start date Start date
Z

Zeba

Hi guys,

I gave the following code in the page load function of one of my
codebehind pages :

if (!string.IsNullOrEmpty(keyword))
{
System.Windows.Forms.MessageBox.Show("Got your keyword!!");
SearchByKeyword();
}

I also included the reference for System.Windows.Forms, but I when I
try to view the page I get the error :

System.InvalidOperationException: 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.
What does this mean ?

Thanks!
 
So then in what context would you use

System.Windows.Forms.MessageBox.Show("sometext");

Thanks!
 
Zeba,

Also, you don't have to write on the page if you don't want to. You can
insert text into the page which will call the Javascript function alert (on
the inherent window object exposed by the browser) in order to show a
messagebox on the client.

Hope this helps.
 
Back
Top