如何使用C#在ASP.NET中显示消息框

编程入门 行业动态 更新时间:2024-10-10 13:19:03
本文介绍了如何使用C#在ASP.NET中显示消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何使用C#在ASP中显示消息框(请帮忙)

How to display messagebox in ASP using C# (Please help)

推荐答案

在Windows应用程序中,您可以使用: MessageBox.Show(您的消息); 在Web应用程序中,您可以使用服务器端代码中的java脚本 Page.ClientScript.RegisterStartupScript(this.GetType(),scriptkey,alert) ('您的消息');); In windows Application you can use : MessageBox.Show("your message"); In web Applications you can use java script from server side code Page.ClientScript.RegisterStartupScript(this.GetType(),"scriptkey","alert('your message');");

在您的页面中添加脚本代码: add script code in your page: <script type="text/javascript"> function Showalert() { alert('Call JavaScript function from codebehind'); } </script> here is code for display the alert message... It is similar to msgbox. <pre> <div> <asp:Button ID="btnSubmit" runat="server" Text="Show alert" onclick="btnSubmit_Click"/> <asp:Button ID="btnClick" runat="server" Text="Call JavaScript Function" onclick="btnClick_Click" /> </div>

我希望这对你有帮助。

I hope this is help for You.

您可以添加System.Window.Form的引用,这将在您的asp应用程序中添加MessageBox,当您处于调试模式时,这是好的,只是您想要测试您的网站。但是当你主持你的网站时,问题就出现了,这意味着生产阶段。 你的javascript更好。 You can add reference of System.Window.Form, that would give to add MessageBox in your asp application, it is good when you are in debug mode mean only you want to test your website. But problems come when you host you host your website, mean production phase. Better you you javascript.

更多推荐

如何使用C#在ASP.NET中显示消息框

本文发布于:2023-11-27 16:12:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638701.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   消息   ASP   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!