MessageBox.Show

  • Thread starter Thread starter Kiyomi
  • Start date Start date
K

Kiyomi

Hello,

I use in my application MessageBox.Show and it works perfectly when I run
this application on my local computer (http://localhost). When I diployed
this application on the server, however, it does not work. It does not give
me even an error message, but the screen is just freezed (it is running open
the page). What are the requirements for the MessageBox.Show to work ? I
suppose something is missiong on the server as the same MessageBox.Show
works well on my local computer.

Thank you for your advice,

Kiyomi
 
I use in my application MessageBox.Show and it works perfectly when I run
this application on my local computer (http://localhost). When I diployed
this application on the server, however, it does not work. It does not give
me even an error message, but the screen is just freezed (it is running open
the page). What are the requirements for the MessageBox.Show to work ? I
suppose something is missiong on the server as the same MessageBox.Show
works well on my local computer.

Is this a ASP.NET web application? If so you shouldn't be using
MessageBox, it's for windows applications.


Mattias
 
Thank you, Mattias, for your prompt reply. Yes, it is a ASP.NET web
application. I should use javascript instead, then. But I wonder why it
works on my local computer ?

Thank you,

Kiyomi
 
When you say "works", you mean that the message box shows up on the system
where the .NET code is running, yes? So that's your system when you're in
development mode, and the IIS server when it's deployed. So as far as you
know it might actually be working, showing a message box on the server (or
at least trying to). The messagebox on the server might be running in an
environment where it just won't show because it's showing in an invisible
Windows station context. I'm assuming you're debugging or something because
it's not very useful for a user to be sitting there with a dead web page
because a messagebox is showing on some remote server somewhere.
--
Phil Wilson [MVP Windows Installer]
----
Kiyomi said:
Thank you, Mattias, for your prompt reply. Yes, it is a ASP.NET web
application. I should use javascript instead, then. But I wonder why it
works on my local computer ?

Thank you,

Kiyomi
 
[font=Verdana, Arial, Helvetica][font=Verdana, Arial, Helvetica]Using MessageBox.Show() this way will work, but only displays on the server. The reason for this is that the server is where your code is being processed. To get this to work on the client side you'll need to use code that is processed on the client side, like javascript.

The best way I've found to do this is to create a static class MessageBox with a static method Show(), which will give you the ablility to to still use the syntax MessageBox.Show("Your Message"); and convert it into window.alert("Your Message");.

The javascript alert() function is limited as it doesn't provide any overloads for changing the caption of the MessageBox, but it still works nicely.

I've written a how to on my blog at: http://sceptermt.blogspot.com/2008/02/how-to-create-message-box-class-in-c.html that shows the source code that I used in C# for my web application and details on how it works.

You could also write overloads for the static show() method to allow the class to do a javascript confirm() or a prompt(). I haven't needed that functionality yet so I've just kept it simple.
[/font][/font][font=Verdana, Arial, Helvetica][font=Verdana, Arial, Helvetica][/font][/font]
 
Back
Top