Check empty variable. Strange problem. Need Help.

Discussion in 'ASP .Net' started by Shapper, May 9, 2005.

  1. Shapper

    Shapper Guest

    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
    Shapper, May 9, 2005
    #1
    1. Advertising

  2. Shapper

    gabe garza Guest

    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:%...
    > 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
    >
    gabe garza, May 10, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shapper

    Check if variable is empty

    Shapper, May 16, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    16,180
    William F. Robertson, Jr.
    May 17, 2005
  2. John

    empty/non-empty element

    John, Jul 15, 2003, in forum: XML
    Replies:
    1
    Views:
    1,009
    Klaus Johannes Rusch
    Jul 16, 2003
  3. Lukas
    Replies:
    3
    Views:
    782
    spiff
    Nov 10, 2005
  4. Marcia Hon

    Check if a directory is empty and empty it

    Marcia Hon, Feb 8, 2004, in forum: C Programming
    Replies:
    8
    Views:
    562
    Dave Thompson
    Feb 14, 2004
  5. Brian Roberts

    empty lists vs empty generators

    Brian Roberts, May 3, 2005, in forum: Python
    Replies:
    12
    Views:
    640
    Jeremy Bowers
    May 4, 2005
Loading...

Share This Page