现在的位置: 首页 > 综合 > 正文

Winform与Webform中的对话框

2012年12月31日 ⁄ 综合 ⁄ 共 882字 ⁄ 字号 评论关闭
参考MSDN

DialogResult result = MessageBox.Show("见过打劫的没?", "打、打、打劫", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
switch (result)
{
    case DialogResult.OK:
        MessageBox.Show("你按了确定");
        break;
    case DialogResult.Cancel:
        MessageBox.Show("你按了取消");
        break;
}

【lxcnn】:
抱歉,最近头晕,看成winform了,webform我再看下代码

【GaoFX】:
你如果想在CodeBehind代码过程中弹出对话框让用户作出选择,呵呵,俺认为是不可能的。
如果是在页面的客户端脚本中,太多了,可以window.confirm,也可以自己写一个页面showModalDialog显示出来。

【lxcnn】:
看你想实现什么样的效果吧

Response.Write("<script languge=javascript'>if(confirm('你确定结贴?')){alert('你按了确定')}else{alert('你按了取消')}</script>");

另一种是在Page_Load里加
Button1.Attributes.Add("onclick", "return confirm('你确定要结帖吗?')");
点确定执行Click事件,点取消则不执行

【yanming_01】:
假设你要实现的是删除一条语句    
但你要做2次判断

用个textBox来说明
if(){Response.Write("<script>alert('你却定删除吗!');</script>");}
    else 
{Response.Write("<script>alert('取消删除!');</script>");}

抱歉!评论已关闭.