views:

344

answers:

5

I tried but I guess Message Box only works with win forms. What is the best alternative to use in web forms?

+2  A: 
result = confirm('Yes or no question here.')
Patrick McElhaney
A: 

JavaScript:

alert("This box has an OK button.");
BoltBait
+6  A: 

You can use confirm for yes/no questions and alert for "OK" messages in JavaScript.

The other alternative is to use JavaScript to pop up a new window that looks and acts like a message box. Modality in this case varied by browser. In Internet Explorer, the method

window.showModalDialog(url,name,params)

will display a modal dialog. The Mozilla approach is to still use

window.open(url,name,params)

but add modal=yes to the params list.

DocMax
A: 

The Ajax ModalPopup also works nicely. Here is an example:

http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx

A: 

You have dojo dialog widget: http://www.dojotoolkit.org/ and you can use it as a message box.

milot