Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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

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

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top