Home
Manage Your Code
Snippet: Textbox & String.Empty (C#)
Title: Textbox & String.Empty Language: C#
Description: Examine TextBox value to determine whether it is empty Views: 513
Author: liu bin Date Added: 8/26/2007
Copy Code  
1// ????????,?????,????Login??,????????...
2        private bool CheckTextbox()
3        {
4            // ??????????
5            userName = this.txtUserName.Text.Trim().TrimEnd();
6            password = this.txtPassword.Text;
7            // ?????
8            if (userName == String.Empty)
9            {
10                MessageBox.Show("?????,?????!", "??", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
11                return false;
12            }
13            else
14            {
15                MessageBox.Show("????:" + userName + "----??" + userName.Length);
16
17                // ??????
18                if (password == String.Empty)
19                {
20                    MessageBox.Show("??????,?????!", "??", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
21                    return false;
22                }
23            }
24
25            return true;
26        }