2014-12-19 66 views

回答

0

在你Button_click情况下,添加一个条件,

if (!String.IsNullOrEmpty(PhoneTextBox.Text)) 
{ 
    //your action here 
} 
+0

它给出错误! – 2014-12-19 08:50:34

+0

@saravanann你能指定什么错误吗? – 2014-12-19 19:14:11

0

在你Button的事件处理程序,请确保您有:

your eventhandler(){ 
if(string.IsNullOrWhiteSpace(this.textBox1.Text)) //here "tb" is the textbox name, in case of that give your textbox's name. 
{ 
MessageBox.Show("TextBox is empty"); 
} 
} 

否则试图尽可能使用String.IsNullOrWhiteSpace检查是否字符串是空的。

if (String.IsNullOrWhiteSpace(Name)) //give the name of your textbox.Text 
{ 
//Handled 
} 

参考:String.IsNullOrWhiteSpace Method

0

Button_click你必须检查。尝试下面的代码。

if (!String.IsNullOrEmpty(YourTextBox.Text)) // it check it text box is null or empty 
{ 
    //your action here 
} 
相关问题