如何展现在ASP.NET页面一个消息框? [英] How to show a message box in an ASP.NET page?

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

问题描述

因为我是一个Windows程序员它是那么容易显示窗体上的消息框。

As I was a Windows programmer it was so easy to show a message box on a form.

可是,在一个 ASP.NET 页面,我不知道我该怎么让呢?

But on an ASP.NET page I don't know how can I show it?

其实,我有一些条件,基于我要显示一个消息框,用户得到他/她的反应,并基于该响应我要继续。
例如,我想询问用户是否要继续?有两个按钮是&放大器; 否。

Actually I have some condition and based on that I want to show a message box to the user to get his/her response and based on that response I want to continue. For example I want to ask the user "Do you want to continue?" with two buttons "Yes" & "No".

推荐答案

要显示是无对话的唯一途径,就是设计一个自定义(JavaScript的confirm只能产生确定和取消)。

The only way to show a Yes No dialog, is to design a custom one (Javascript confirm can only produce OK and Cancel).

幸运的是,ASP.NET Ajax控件(Ajaxcontroltoolkit),使这工作很容易,因为你可以有一个面板与你想要的按钮的消息框,并有一个ModalPopupExtender模仿的对话框。

Luckily, ASP.NET Ajax controls (Ajaxcontroltoolkit) makes this job easy, as you can have a panel as your messagebox with the buttons you want, and have a ModalPopupExtender to imitate a dialog.

编辑:

有关你使用javascript问,你可以做到这一点(它是一个更简单的解决方案,因此比任何看到的),但ppared至$ P $只有确定和取消的两个可能的答案。 UI设计师的噩梦! (

For what you ask with javascript, you can do it (and it is a much simpler solution than any seen so far), but prepared to only have OK and Cancel as the two possible answers. UI Designer Nightmare ! :(

基本上,在你的aspx页面下面的两个属性的按钮或什么:

Basically, have the following two properties in your aspx page for that button or whatever:

onClientClick = "javascript:confirm('you sure you wanna do this?');" onClick="myButton_Click"

如果确定是pssed在MSG对话框$ P $

的onClick才会运行。

onClick will only run if OK is pressed on the msg dialog.

这篇关于如何展现在ASP.NET页面一个消息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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