显示提示框问题 各位大侠,菜鸟有个问题(如下),分不多,见谅.1.点击Bottn2.执行一段sql: select a,b from Table3.if(a>b) 弹出对话框(含确定,取消)4.确定-->继续执行,取消-->返回 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 [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] if (MessageBox.Show(this, "是否确定?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } 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>"); } } 一楼二楼MessageBox.Show()似乎只能用在WinForm下吧我用的是WebForm该怎么办呢三楼我是想在一个提框中有"确定"和"取消" //删除事件 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('你确定要删除吗?');这个就是提示框.... //删除事件 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('你确定要删除吗?');这个就是提示框.... System.Timers.Timer不断地吃掉内存???(内附完整源码) 做网站时怎么弄界面最好?在线等! usercontrol的keyup事件问题 asp.net datagrid排序的问题 梅花雨的Calendar.js在ASP.NET2.0中使用为什么会出错?谁能帮忙解决? 双表数据查询语句不会写.请求HELP...... Access数据连接问题 通过c#将oracle与sqlserver 互连的问题 求助,关于windows media player 怎么通过FTP实现两台电脑对用文件的及时更新 文件读写的问题 数组的比较(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]
{ return; }
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>");
} }
MessageBox.Show()似乎只能用在WinForm下吧
我用的是WebForm该怎么办呢
三楼
我是想在一个提框中有"确定"和"取消"
//删除事件
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('你确定要删除吗?');这个就是提示框....
//删除事件
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('你确定要删除吗?');这个就是提示框....