各位大侠,菜鸟有个问题(如下),分不多,见谅.
1.点击Bottn
2.执行一段sql: select a,b from Table
3.if(a>b) 弹出对话框(含确定,取消)
4.确定-->继续执行,取消-->返回

解决方案 »

  1.   

    [code = c#]
         label1.Text="";
         DialogResult MsgBoxResult;//设置对话框的返回值
         MsgBoxResult = MessageBox.Show("请选择你要按下的按钮",//对话框的显示内容
         "提示",//对话框的标题
         MessageBoxButtons.YesNo,//定义对话框的按钮,这里定义了YSE和NO两个按钮
         MessageBoxIcon.Exclamation,//定义对话框内的图表式样,这里是一个黄色三角型内加一个感叹号
         MessageBoxDefaultButton.Button2);//定义对话框的按钮式样
         if (MsgBoxResult == DialogResult.Yes)//如果对话框的返回值是YES(按"Y"按钮)
            {
               this.label1.ForeColor = System.Drawing.Color.Red;//字体颜色设定
               label1.Text=" 你选择了按下”Yes“的按钮!";
            }
         if(MsgBoxResult == DialogResult.No)//如果对话框的返回值是NO(按"N"按钮)
            {
                this.label1.ForeColor = System.Drawing.Color.Blue;//字体颜色设定
                 label1.Text=" 你选择了按下”No“的按钮!";
             }
    [/code]
      

  2.   

    if (MessageBox.Show(this, "是否确定?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                { return; }
      

  3.   


     private void btnLogin_Click(object sender, EventArgs e)
            {
                SqlConnection yy = new SqlConnection(); //数据库连接
                yy.ConnectionString = "server=.;database=logins;uid=sa;pwd=sa"; //设定连接字符串
                yy.Open(); //打开连接
                SqlCommand nn = new SqlCommand(); //数据库命令,sql
                nn.Connection = yy;
                nn.CommandText = "select * from users where UserName = @name"; //sql语句,用于取得name指定的一行
                nn.Parameters.Add(new SqlParameter("@name", txtUser.Text)); //设定name条件为txtUser得值
                SqlDataReader rr = nn.ExecuteReader(); //执行sql语句 ExecuteReader
                if (rr.Read()) //读取纪录
                {
                    if (rr[2].ToString() == txtPwd.Text) //如果密码正确
                    {
                        string  str  = txtPwd.Text;
                       Response.Write("<script>alert('登录成功!');window.location.href='Default.aspx?txtName=" + str + "'</script>");      
                  }
                    else //密码错误
                    {
                   Response.Write("<script>alert('密码错误,请重新输入!');</script>");                  }
                }
                else //没有记录,用户名不存在
                {
                   Response.Write("<script>alert('用户名不存在,请重新输入!');</script>");  
                }         }
      

  4.   

    一楼二楼
    MessageBox.Show()似乎只能用在WinForm下吧
    我用的是WebForm该怎么办呢
    三楼
    我是想在一个提框中有"确定"和"取消"
      

  5.   


        //删除事件
        protected void gvDepart_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton imgbtnDelete = e.Row.FindControl("imgbtnDelete") as ImageButton;
                imgbtnDelete.Attributes.Add("onclick", "return confirm('你确定要删除吗?')");        }
        }
    confirm('你确定要删除吗?');这个就是提示框....
      

  6.   


        //删除事件
        protected void gvDepart_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton imgbtnDelete = e.Row.FindControl("imgbtnDelete") as ImageButton;
                imgbtnDelete.Attributes.Add("onclick", "return confirm('你确定要删除吗?')");        }
        }
    confirm('你确定要删除吗?');这个就是提示框....