文本框文本仅检查一次
我有2个面板。如果文本框为空,则有一条消息。我的问题是,说我进入第二个面板,然后返回并删除文本,然后再次转到第二个面板,它不会显示消息。有没有办法每次检查文本?
private void bttn_Next_Click(object sender, EventArgs e)
{
if (txt_FirstName.Text == " " || txt_LastName.Text == " " ||
txt_Email.Text == " " || txt_Contact.Text == " " ||
txt_HouseNumber.Text == " " || txt_Street.Text == " " ||
txt_Barangay.Text == " " || txt_Municipality.Text == "")
{
MessageBox.Show("Please complete all required fields.", "Message");
}
else
{
panel1.Hide();
panel2.Hide();
panel3.Show();
}
}
I have 2 panels. If textboxes are empty, there is a message. My problem is, say I get to second panel then go back and delete texts then go to second panel again, it does not show message. Is there a way to check the texts every time?
private void bttn_Next_Click(object sender, EventArgs e)
{
if (txt_FirstName.Text == " " || txt_LastName.Text == " " ||
txt_Email.Text == " " || txt_Contact.Text == " " ||
txt_HouseNumber.Text == " " || txt_Street.Text == " " ||
txt_Barangay.Text == " " || txt_Municipality.Text == "")
{
MessageBox.Show("Please complete all required fields.", "Message");
}
else
{
panel1.Hide();
panel2.Hide();
panel3.Show();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查空字符串的正确方法如下
The correct way to check for empty string is as follows