Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Check empty variable. Strange problem. Need Help.

Reply
Thread Tools

Check empty variable. Strange problem. Need Help.

 
 
Shapper
Guest
Posts: n/a
 
      05-09-2005
Hello,

I need to check if a textbox is returning an empty value.
When I use Response.Write(myTextBox.Text) I get the written value.

However, when I use the code:
If myTextBox.Text Is Nothing Then
Response.Write("Empty")
End If

"Empty" doesn't show even if I don't write anything in the text box.
Am I doing something wrong?

Thanks,
Miguel

 
Reply With Quote
 
 
 
 
gabe garza
Guest
Posts: n/a
 
      05-09-2005
You use "Nothing" to see if an object exists or not.
To see if your TextBox has something, check it's Length property. If it's 0
then you don't have anything in the TextBox.


"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%(E-Mail Removed)...
> Hello,
>
> I need to check if a textbox is returning an empty value.
> When I use Response.Write(myTextBox.Text) I get the written value.
>
> However, when I use the code:
> If myTextBox.Text Is Nothing Then
> Response.Write("Empty")
> End If
>
> "Empty" doesn't show even if I don't write anything in the text box.
> Am I doing something wrong?
>
> Thanks,
> Miguel
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DetailsView ASP Control and an empty field not an empty record. ButlerDJIAM ASP .Net 0 11-09-2006 06:40 PM
Altova Mapforce - xml 2 xml map: empty elements output although input element is not empty Lukas XML 3 11-10-2005 02:25 PM
empty lists vs empty generators Brian Roberts Python 12 05-04-2005 08:59 PM
Check if a directory is empty and empty it Marcia Hon C Programming 8 02-14-2004 03:53 AM
empty/non-empty element John XML 1 07-16-2003 10:23 AM



Advertisments