For Programmers: Free Programming Magazines  


Home > Archive > ASP > November 2005 > Hiding blank record data









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Hiding blank record data
james.shearer@gmail.com

2005-11-24, 6:55 pm

I want to display the contents of a field with a label if there is data

in that field. If there isn't then I don't want the label to appear.

I tried this:

<%If Venueinfo("email") = "" Then
Else%>Email: <a href="mailto:<%=Venueinfo("email")%>">Click to
email</a><br><%End If%>

But it doesn't seem to work. It seems to always display the label and
link even though there is no data in that field.

help?

this is ASP and mysql

MyndPhlyp

2005-11-24, 6:55 pm


<james.shearer@gmail.com> wrote in message
news:1132866056.630720.6850@z14g2000cwz.googlegroups.com...
> I want to display the contents of a field with a label if there is data
>
> in that field. If there isn't then I don't want the label to appear.
>
> I tried this:
>
> <%If Venueinfo("email") = "" Then
> Else%>Email: <a href="mailto:<%=Venueinfo("email")%>">Click to
> email</a><br><%End If%>
>
> But it doesn't seem to work. It seems to always display the label and
> link even though there is no data in that field.


Is the field really "", or is it Empty, or is it Null?

"" <> Empty <> Null

To cover all the bases:

If Venueinfo("email") = "" Or IsNull(Venueinfo("email")) Or
IsEmpty(Venueinfo("email")) Then


Bob Barrows [MVP]

2005-11-25, 7:55 am

MyndPhlyp wrote:
>
> To cover all the bases:
>
> If Venueinfo("email") = "" Or IsNull(Venueinfo("email")) Or
> IsEmpty(Venueinfo("email")) Then


A good hack to use is this:

if Venueinfo("email") & "" = "" then

Given the fact that operations involving Null are supposed to result in
Null, one would not expect this hack to work. However, in both VB and
vbscript, concatenation with Null does not result in Null, so the above hack
works.


Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


MyndPhlyp

2005-11-25, 7:55 am


"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:e9X6A8b8FHA.132@TK2MSFTNGP15.phx.gbl...
> MyndPhlyp wrote:
>
> A good hack to use is this:
>
> if Venueinfo("email") & "" = "" then


I almost included that in my earlier reply. Definitely a slick and elegant
hack. I have been aware of it for quite some time but choose not to use it
for a couple of reasons: (a) it relies upon a quirk, and (b) it doesn't
document very well to the unenlightened developer.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com