如何使用C#在ASP.NET中显示消息框 [英] How to display messagebox in ASP.NET using C#

查看:69
本文介绍了如何使用C#在ASP.NET中显示消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



How to display messagebox in ASP.net 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.net应用程序中添加MessageBox,当您处于调试模式时,这是好的,只是您想要测试您的网站。但是当你主持你的网站时,问题就出现了,这意味着生产阶段。

你的javascript更好。
You can add reference of System.Window.Form, that would give to add MessageBox in your asp.net 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中显示消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆