views:

251

answers:

3

Can anyone please tell me about how to show message box in MVC application. I don't want to use System.Windows.Forms.MessageBox. Additionaly i want to catch the response of button click e.g. If we press OK we should get a value. As it is in the case of System.Windows.Forms.MessageBox. Is there any way?

Thanks, Kaps

+1  A: 

use jquery dialog: http://jqueryui.com/demos/dialog/

Jack
+2  A: 

There is a function baked into JavaScript that you could use but it is pretty ugly and using something like the jQuery Dialog would probably be best. Here it is anyway:

var answer = confirm("Are you sure");
David Radcliffe
Can I show "Yes" and "No" buttons.
kapil
Yes, but the buttons are "ok" and "cancel" and you can't change that.
David Radcliffe
A: 

You should use javascript. There are a lot of options out there (jQueryUI, ExtJS,etc), the simplest one is using javascript built-in prompt box.

function prompt()
{
var name=prompt("Please enter your name:","Your name");
//do your logic
}

Anton Setiawan
How can i use it in controller of MVC application?
kapil
You will only use javascript in your View. If you want to send user input to server then you also have to create to create a controller action to accept your input
Anton Setiawan