private void button1_Click(object sender, EventArgs e)
{
String this_url, this_timer;
this_url = textBox1.Text;
this_timer = textBox2.Text;
if (this_url == "")
{
MessageBox.Show("请输入回调网址!");
textBox1.Focus();
}
if (this_timer == "")
{
MessageBox.Show("请输入刷新时间!");
textBox2.Focus();
}
}
---
为什么textBox1.Text为空时,有提示信息,却textBox2.Text为空时就没有了?
{
String this_url, this_timer;
this_url = textBox1.Text;
this_timer = textBox2.Text;
if (this_url == "")
{
MessageBox.Show("请输入回调网址!");
textBox1.Focus();
}
if (this_timer == "")
{
MessageBox.Show("请输入刷新时间!");
textBox2.Focus();
}
}
---
为什么textBox1.Text为空时,有提示信息,却textBox2.Text为空时就没有了?
试下这个
if (this_url == "")
{
MessageBox.Show("请输入回调网址!");
textBox1.Focus();
}
else
{
if (this_timer == "")
{
MessageBox.Show("请输入刷新时间!");
textBox2.Focus();
}
}
第二个没有提示可能是你textBox2控件的Text有空白
你可以用textBox2.Text.trim()
{
if (textBox1.Text.Trim() == "")
{
MessageBox.Show("请输入回调网址!");
textBox1.Focus();
}
if (textBox2.Text.Trim() == "")
{
MessageBox.Show("请输入刷新时间!");
textBox2.Focus();
}
}
this_url = textBox1.Text.Trim(); this_timer = textBox2.Text.Trim();
this_timer = textBox2.Text.Trim();
用这个试试,不过,lz的代码,在我机器上是正确的,两个都会有提示信息
lz在好好查一下.查一下this_timer.length是多少
MessageBox.Show("请输入回调网址!");
textBox1.Focus();
}
else if(this_timer == ""){
MessageBox.Show("请输入刷新时间!");
textBox2.Focus();
}else{
//do something here
}检查一下你的VS.net或.net framework环境配置这些正确吗?