Furqan Sehgal
Furqan Sehgal

Reputation: 4997

Message box in asp.net, using vb.net code

When I display message box using msgbox ("Show my message") in asp.net webforms, it does show it but in minimized state.
How to display it normally as we get it in winforms?

Thanks

Upvotes: 1

Views: 19416

Answers (3)

jrummell
jrummell

Reputation: 43107

You can't display a server side MessageBox in a web application. You can use the javascript alert dialog, a modal dialog, a UserControl, or a block of text on your page instead.

The simplest method is probably alert:

<script type='text/javascript'>
  alert("Show my message");
</script>

Upvotes: 2

Paolo Falabella
Paolo Falabella

Reputation: 25874

You can't use a msgbox (it may work when you're testing the application locally because your machine is both the client and the server, but if you tried to deploy it, it may only open a msgbox on the server).

You can use javascript, like this:

SomethingClickable.Attributes["onClick"] = "alert('Hello World');";

Upvotes: 3

Stilgar
Stilgar

Reputation: 23591

You can't directly display e message box on the client from the server. You need to use JavaScript code which happens to be

alert("Show my message");

However you can't put that directly in the VB code. You should somehow render it on the page and if you need it as a result of some interaction you should handle that interaction again on the client. If you need code to run on the server the user should either refresh the page and be greated with the message box when it loads or you should use some kind of AJAX (UpdatePanel, services, etc.)

Moral of the story: the web is not the desktop.

Upvotes: 1

Related Questions