简体   繁体   中英

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

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');";

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM