views:

1033

answers:

4

Hi,

I've been trying to do a messagebox in a controller in asp.net mvc, but every time I type MessageBox or MsgBox it doesn't give me the option to import a namespace...

What can I use that would be similar to a MessageBox?

+5  A: 

the MessageBox functionality is provided by the System.Windows library which is not available in the ASP.NET MVC context, since your site is running within a browser.

Instead, you should use a javascript library to show a message box.

You could use the following in order to display a message box

alert('Hi there')
Konstantinos
well I need to be able to see what's going on in the backend, I can't really alert backend variables from javascript while the backend code is running.
Matt
you mean you want the user to take a decision which the backend will use in order to render or work on something?
Konstantinos
+1  A: 

you could render out a script tag as a actionresult that has

alert('{0}'); where the placeholder is you message

almog.ori
A: 

Message box can be shown using Javascript, you can write your own HtmlHelper for this or have a partial which takes the message as input and diplays it, in this way you can reuse your partial

Rony
A: 

I suggest using the jQuery UI dialog. It's incredibly easy to use, very powerful, and really easy to style.

Wedge