C# 如何在 Visual Studio 2008 中使用 .cs 代码在 Web 表单中显示消息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1187148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you display a message in web forms using .cs code in visual studio 2008?
提问by
In visual studio 2005, we can get message.show() to display the message.I required the method in visual studio 2008.
在visual studio 2005中,我们可以使用message.show()来显示消息。我需要visual studio 2008中的方法。
回答by RichardOD
This hasn't changed in 2008. Are you sure you mean Web forms, it sounds more like you mean Windows Forms- see here: http://msdn.microsoft.com/en-us/library/system.windows.forms.messagebox.show.aspx
这在 2008 年没有改变。您确定您的意思是 Web 表单吗,听起来更像是 Windows 表单 - 请参阅此处:http: //msdn.microsoft.com/en-us/library/system.windows.forms。消息框.show.aspx
If you need further help please elaborate your question.
如果您需要进一步的帮助,请详细说明您的问题。
回答by gius
I don't believe that there is any change in the code from VS2005 to VS2008. But accordnig to the title of your question ("diplay a message in web forms"), I assume that you are using ASP.NET (if you meant win forms, RichardOD has already answered your question).
我不相信从 VS2005 到 VS2008 的代码有任何变化。但是根据您问题的标题(“在 Web 表单中显示消息”),我假设您使用的是 ASP.NET(如果您的意思是赢得表单,RichardOD 已经回答了您的问题)。
You should use javascript function
你应该使用javascript函数
alert('This is my message.');
to show the message.
显示消息。
Check thisarticle - it contains a great implementation that you can use right as a MessageBox in winforms.
检查这篇文章 - 它包含一个很好的实现,您可以在 winforms 中将其用作 MessageBox。
回答by Galilyou
You probably mean MessageBox.Show(). MessageBox is a class in the System.Windows.Forms namespace; this class contains the Show method which when called, should draw a window on a screen. Now this is all different with web! Web is not a one machine application like your windows form, web is a client/server architecture, where there are two major parts of your application: the server where you deploy your code, and the client (the browser responsible for rendering the output of your code). I will not digg in much details for now, I strongly recommend that you learn about the web and its Client/Server architecture first.
Thanks
您可能是指 MessageBox.Show()。MessageBox 是 System.Windows.Forms 命名空间中的一个类;此类包含 Show 方法,调用该方法时,应在屏幕上绘制一个窗口。现在这与网络完全不同!Web 不是像 Windows 窗体那样的单机应用程序,Web 是客户端/服务器架构,其中应用程序有两个主要部分:部署代码的服务器和客户端(负责呈现输出的浏览器)您的代码)。我现在不会深入挖掘细节,我强烈建议您首先了解 Web 及其客户端/服务器架构。
谢谢
回答by Jeeva Subburaj
if it is webform, you could use
如果是网络表单,您可以使用
Response.Write("Your Message")
Method.. if you want the message box, you could use javascript
方法..如果你想要消息框,你可以使用javascript
alert('your message')
if it is windows forms, use
如果是 windows 窗体,请使用
Messagebox.Show("your message")
hope this helps u
希望这对你有帮助