Windows phone 8 windows phone app 8中PhoneTextBox的输入验证
我正在开发一个windows phone应用程序。在我的应用程序中,我想对textbox进行输入验证。我正在使用windows phone toolkit:PhoneTextBox windows phone toolkit :PhoneTextBox 当用户在单击提交按钮后未能填写文本框时,需要发出警告消息。有什么方法可以做到这一点吗Windows phone 8 windows phone app 8中PhoneTextBox的输入验证,windows-phone-8,Windows Phone 8,我正在开发一个windows phone应用程序。在我的应用程序中,我想对textbox进行输入验证。我正在使用windows phone toolkit:PhoneTextBox windows phone toolkit :PhoneTextBox 当用户在单击提交按钮后未能填写文本框时,需要发出警告消息。有什么方法可以做到这一点吗 谢谢 在按钮中单击事件,添加条件 if (!String.IsNullOrEmpty(PhoneTextBox.Text)) { //your acti
谢谢 在
按钮中单击事件,添加条件
if (!String.IsNullOrEmpty(PhoneTextBox.Text))
{
//your action here
}
在按钮的事件处理程序中,确保您具有:
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
}
参考资料:在按钮上单击您必须检查的。试试下面的代码
if (!String.IsNullOrEmpty(YourTextBox.Text)) // it check it text box is null or empty
{
//your action here
}