Easiest way to check for empty text box in .net

We can check for empty text box in various ways including javascript.
But easier way I have found is:-

textbox.text.trim()==string.empty;

You can use this code in codebehind file and check it in IF condition.
It also ensures if text box contains only space. This is ensured by trim function.

Downside for this is that, u need to give postback call to server, which could also be acheived by client side script and network traffic would have reduced...

Comments

Popular posts from this blog

Weekend Gateway Trip - Shrivardhan

Cross Apply Incorrect syntax near '.'

Apply CSS Class based on Browser