如何在asp.net mvc中创建消息框?

时间:2022-10-21 04:14:20

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...

我一直在尝试在asp.net mvc中的控制器中做一个消息框,但每次我输入MessageBox或MsgBox时它都没有给我导入命名空间的选项......

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

我可以使用哪些类似于MessageBox?

4 个解决方案

#1


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

消息框可以使用Javascript显示,您可以为此编写自己的HtmlHelper,或者有一个部分将消息作为输入并显示它,这样您就可以重用部分

#2


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.

MessageBox功能由System.Windows库提供,由于您的站点在浏览器中运行,因此ASP.NET MVC上下文中不提供该功能。

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

相反,您应该使用JavaScript库来显示消息框。

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

您可以使用以下内容来显示消息框

alert('Hi there')

#3


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

您可以将脚本标记呈现为具有的动作结果

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

警报( '{0}');占位符是你的消息

#4


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

我建议使用jQuery UI对话框。它非常易于使用,非常强大,而且非常容易打造。

#1


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

消息框可以使用Javascript显示,您可以为此编写自己的HtmlHelper,或者有一个部分将消息作为输入并显示它,这样您就可以重用部分

#2


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.

MessageBox功能由System.Windows库提供,由于您的站点在浏览器中运行,因此ASP.NET MVC上下文中不提供该功能。

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

相反,您应该使用JavaScript库来显示消息框。

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

您可以使用以下内容来显示消息框

alert('Hi there')

#3


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

您可以将脚本标记呈现为具有的动作结果

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

警报( '{0}');占位符是你的消息

#4


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

我建议使用jQuery UI对话框。它非常易于使用,非常强大,而且非常容易打造。