为什么我的IF语句不起作用?
private void btnxuyuan_Click(object sender, System.EventArgs e){
if(this.txtuserName.Text==null)
{
Response.Redirect("main.aspx");
}
else
{
OleDbConnection conn=new OleDbConnection();
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+Server.MapPath
(@"\xuyuan\data\xuyuan.mdb");
conn.Open();//连接数据库
string SQLStr;//定义字符串变量SQLStr
SQLStr="insert into wish(userName,userlaizi,geishui) values('"+txtuserName.Text+"','"+txtuserFrom.Text+"','"+txtsendTo.Text+"')";
OleDbCommand Cmd=new OleDbCommand(SQLStr,conn);//定义命令
Cmd.ExecuteNonQuery();//执行
this.DataBind();
this.BindToDataList();
conn.Close();
Response.Redirect("myWeb.aspx");
}
我想判断如果一个TEXTBOX为空时不执行插入,但是我不能用验证控件,用JS也行!请教高手~~~~~~~`