Reputation: 1
I am new at programming in c# in visual studio 2010. I have been trying to figure out When I click my save button my text boxes cannot be null or empty. I would appreciated if you guys could let me to a path in how to solve this.
Upvotes: 0
Views: 2401
Reputation: 498952
You need to test the value of the text boxes (.Text
property) to see if it is filled.
Using the string.IsNullOrWhitespace
(.NET 4.0 and above) or string.IsNullOrEmpty
methods in an if
statement is a good start.
if(!string.IsNullOrWhitespace(aTextBox.Text))
{
// it is not empty or null!
}
Upvotes: 2