如何使用消息框. [英] how to use message box.

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

问题描述

当我单击网页上的链接时,它应该显示一条消息,提示您要继续吗" .这应该在下面的函数中完成

when I click on a link in my web page,it should display a message saying"Do you want to continue".This should be done inside the below function

protected void lnk_click(object sender, EventArgs e)
{

}


我可以在这里使用MessageBox.Show吗?但是当我尝试使用它时,出现了一个错误


can I use MessageBox.Show here. But when I tried using it gave me an error

推荐答案

否.

MessageBox(如果使用过的话)将显示在服务器上,而不是客户端上.
要在客户端上显示消息框,您需要使用javascript.参见此处:在ASP.NET网页中添加客户端消息框 [
No.

MessageBox (if you used it) would show on the server, not the client.
To display a message box on the client, you need to use javascript. See here: Adding Client-Side Message Boxes in your ASP.NET Web Pages[^]


您可以使用一个Asp.Net按钮以显示如下所示的MessageBox:-
You can use an Asp.Net button to show a MessageBox like this:-
<asp:button ID="Button1" runat="server" Text="Confirm" OnClientClick="return confirm('Are you sure you want to continue?');"/> 


您也可以注册您的服务器端的javascript如下:

You can also register your javascript from server side as follows:

protected void lnk_click(object sender, EventArgs e)
{

      string javaScript ="<script language=JavaScript>\n" +
                   "confirm('Are you sure you want to continue?');" +
                   "</script>";
      Page.RegisterStartupScript("Confirmation", javaScript);
}


这篇关于如何使用消息框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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