2014-12-19 47 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 
} 
相關問題