Check if TextBox is empty and return MessageBox?

后端 未结 8 1338
谎友^
谎友^ 2020-12-23 22:19

I made this statement to check if TextBox is empty, but the MessageBox always shows up wether the TextBox is empty or not.

    private void NextButton_Click         


        
8条回答
  •  梦毁少年i
    2020-12-23 22:35

    Try doing the following

    if (String.IsNullOrEmpty(MaterialTextBox.Text) || String.IsNullOrWhiteSpace(MaterialTextBox.Text))
        {
            //do job
        }
        else
        {
            MessageBox.Show("Please enter correct path");
        }
    

    Hope it helps

提交回复
热议问题