if (TxtSearch.Text == string.Empty) { return; } else code example Example: c# check if string is empty if (string.IsNullOrEmpty(myString)) { // }