我正在開發一個Windows Phone應用程序。在我的應用程序,我想輸入驗證textbox.i'm使用輸入驗證的PhoneTextBox在Windows Phone應用程序8
windows phone toolkit :PhoneTextBox需要提醒消息,當用戶未能填補文本框中點擊提交button.is有辦法做到這一點?
謝謝!
我正在開發一個Windows Phone應用程序。在我的應用程序,我想輸入驗證textbox.i'm使用輸入驗證的PhoneTextBox在Windows Phone應用程序8
windows phone toolkit :PhoneTextBox需要提醒消息,當用戶未能填補文本框中點擊提交button.is有辦法做到這一點?
謝謝!
在你Button_click
情況下,添加一個條件,
if (!String.IsNullOrEmpty(PhoneTextBox.Text))
{
//your action here
}
在你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
}
在Button_click
你必須檢查。嘗試下面的代碼。
if (!String.IsNullOrEmpty(YourTextBox.Text)) // it check it text box is null or empty
{
//your action here
}
它給出錯誤! – 2014-12-19 08:50:34
@saravanann你能指定什麼錯誤嗎? – 2014-12-19 19:14:11