我正在开发一个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