Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Strange <img> tag behaviour when encapsulated in IF

Reply
Thread Tools

Strange <img> tag behaviour when encapsulated in IF

 
 
Gianpiero Colagiacomo
Guest
Posts: n/a
 
      07-04-2003
VBScript:

Can anyone help me figure out why the image within this IF statement shows
as a place holder rather than the image itself when the statement is
returning true?

If I remove the IF the image shows...

<%
If (events.Fields.Item("picURL").Value) <> "" Then
%>
<img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
border="1
<%
End If
%>

Makes no sense to me... All I want is to show an image if there is a URL
available and nothing if not.

Cheers,

GP



 
Reply With Quote
 
 
 
 
Chris Barber
Guest
Posts: n/a
 
      07-05-2003
Syntax was incorrect.(missing dohble-quotes).

<%
If (events.Fields.Item("picURL").Value) <> "" Then
%>
<img src="<%=events.Fields.Item("picURL").Value%>" alt="URL:
<%=events.Fields.Item("picURL").Value%>" name="pic" border="1">
<%
End If
%>

Hold your mouse over the picture to see the url in the tooltip (remove if
not needed).

Chris.

"Gianpiero Colagiacomo" <(E-Mail Removed)> wrote in message
news:enF$(E-Mail Removed)...
> VBScript:
>
> Can anyone help me figure out why the image within this IF statement shows
> as a place holder rather than the image itself when the statement is
> returning true?
>
> If I remove the IF the image shows...
>
> <%
> If (events.Fields.Item("picURL").Value) <> "" Then
> %>
> <img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
> border="1
> <%
> End If
> %>
>
> Makes no sense to me... All I want is to show an image if there is a URL
> available and nothing if not.
>
> Cheers,
>
> GP
>
>
>



 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      07-05-2003
What's the path to the image? Is it valid as it is returned?

Ray at home

"Gianpiero Colagiacomo" <(E-Mail Removed)> wrote in message
news:enF$(E-Mail Removed)...
> VBScript:
>
> Can anyone help me figure out why the image within this IF statement shows
> as a place holder rather than the image itself when the statement is
> returning true?
>
> If I remove the IF the image shows...
>
> <%
> If (events.Fields.Item("picURL").Value) <> "" Then
> %>
> <img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
> border="1
> <%
> End If
> %>
>
> Makes no sense to me... All I want is to show an image if there is a URL
> available and nothing if not.
>
> Cheers,
>
> GP
>
>
>



 
Reply With Quote
 
Marc
Guest
Posts: n/a
 
      07-05-2003
Maybe the field isn't "" (an empty string) but rather Null
did you try IsNull or IsEmpty?

If that doesn't work try:

myfield = events.Fields.Item("picURL").Value & ""
If myfield <> "" Then
....

Hope that works... let us know!


"Gianpiero Colagiacomo" <(E-Mail Removed)> wrote in message
news:enF$(E-Mail Removed)...
> VBScript:
>
> Can anyone help me figure out why the image within this IF statement shows
> as a place holder rather than the image itself when the statement is
> returning true?
>
> If I remove the IF the image shows...
>
> <%
> If (events.Fields.Item("picURL").Value) <> "" Then
> %>
> <img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
> border="1
> <%
> End If
> %>
>
> Makes no sense to me... All I want is to show an image if there is a URL
> available and nothing if not.
>
> Cheers,
>
> GP
>
>
>



 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      07-05-2003
Gianpiero Colagiacomo wrote on 05 jul 2003 in
microsoft.public.inetserver.asp.general:

> VBScript:
>
> Can anyone help me figure out why the image within this IF statement
> shows as a place holder rather than the image itself when the
> statement is returning true?
>
> If I remove the IF the image shows...
>
> <%
> If (events.Fields.Item("picURL").Value) <> "" Then
> %>
> <img src="<%=(events.Fields.Item("picURL").Value)%>" alt"
> name="pic"
> border="1
> <%
> End If
> %>
>
> Makes no sense to me... All I want is to show an image if there is a
> URL available and nothing if not.


You are right, this makes no sense:

Serverside does not understand "(events.Fields.Item("picURL").Value)",
because asp has no events. [And why the outer (), btw]


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Tammy B.
Guest
Posts: n/a
 
      07-05-2003
fist off, to test use might as well throw away the if then part of your
rstatement.

That leaves -

<img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
border="1

1. You have no closing >
2. Your alt is screwey - it should be alt="something" or no alt at all
3. Third, your border ="1 is wrong
4. the page is trying to interperet <img = gobledygook





"Gianpiero Colagiacomo" <(E-Mail Removed)> wrote in message
news:enF$(E-Mail Removed)...
> VBScript:
>
> Can anyone help me figure out why the image within this IF statement shows
> as a place holder rather than the image itself when the statement is
> returning true?
>
> If I remove the IF the image shows...
>
> <%
> If (events.Fields.Item("picURL").Value) <> "" Then
> %>
> <img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
> border="1
> <%
> End If
> %>
>
> Makes no sense to me... All I want is to show an image if there is a URL
> available and nothing if not.
>
> Cheers,
>
> GP
>
>
>



 
Reply With Quote
 
Gianpiero Colagiacomo
Guest
Posts: n/a
 
      07-05-2003
'Events' is a recordset name. The outer () was placed there by Dreamweaver,
not me!

"Evertjan." <(E-Mail Removed)> wrote in message
news:Xns93AF8697A4B5Beejj99@194.109.133.29...
> Gianpiero Colagiacomo wrote on 05 jul 2003 in
> microsoft.public.inetserver.asp.general:
>
> > VBScript:
> >
> > Can anyone help me figure out why the image within this IF statement
> > shows as a place holder rather than the image itself when the
> > statement is returning true?
> >
> > If I remove the IF the image shows...
> >
> > <%
> > If (events.Fields.Item("picURL").Value) <> "" Then
> > %>
> > <img src="<%=(events.Fields.Item("picURL").Value)%>" alt"
> > name="pic"
> > border="1
> > <%
> > End If
> > %>
> >
> > Makes no sense to me... All I want is to show an image if there is a
> > URL available and nothing if not.

>
> You are right, this makes no sense:
>
> Serverside does not understand "(events.Fields.Item("picURL").Value)",
> because asp has no events. [And why the outer (), btw]
>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)



 
Reply With Quote
 
Gianpiero Colagiacomo
Guest
Posts: n/a
 
      07-05-2003
Path valid. Without the if the image displays.

"Ray at <%=sLocation%>" <(E-Mail Removed)7yasdf.com> wrote in
message news:(E-Mail Removed)...
> What's the path to the image? Is it valid as it is returned?
>
> Ray at home
>
> "Gianpiero Colagiacomo" <(E-Mail Removed)> wrote in message
> news:enF$(E-Mail Removed)...
> > VBScript:
> >
> > Can anyone help me figure out why the image within this IF statement

shows
> > as a place holder rather than the image itself when the statement is
> > returning true?
> >
> > If I remove the IF the image shows...
> >
> > <%
> > If (events.Fields.Item("picURL").Value) <> "" Then
> > %>
> > <img src="<%=(events.Fields.Item("picURL").Value)%>" alt"

name="pic"
> > border="1
> > <%
> > End If
> > %>
> >
> > Makes no sense to me... All I want is to show an image if there is a

URL
> > available and nothing if not.
> >
> > Cheers,
> >
> > GP
> >
> >
> >

>
>



 
Reply With Quote
 
Gianpiero Colagiacomo
Guest
Posts: n/a
 
      07-05-2003
Yeah, sorry that was me trying to trim down the html for the newsgroup. It
actually looks like this:

<%
If (events.Fields.Item("picURL").Value) <> "" Then
%>
<TD> <div align="center">
<img src="<%=(events.Fields.Item("picURL").Value)%>"
alt="<%=(events.Fields.Item("name").Value)%>" name="pic"
border="1"></div></TD>
<%
End If
%>

Cheers,

GP
"Chris Barber" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Syntax was incorrect.(missing dohble-quotes).
>
> <%
> If (events.Fields.Item("picURL").Value) <> "" Then
> %>
> <img src="<%=events.Fields.Item("picURL").Value%>" alt="URL:
> <%=events.Fields.Item("picURL").Value%>" name="pic" border="1">
> <%
> End If
> %>
>
> Hold your mouse over the picture to see the url in the tooltip (remove if
> not needed).
>
> Chris.
>
> "Gianpiero Colagiacomo" <(E-Mail Removed)> wrote in message
> news:enF$(E-Mail Removed)...
> > VBScript:
> >
> > Can anyone help me figure out why the image within this IF statement

shows
> > as a place holder rather than the image itself when the statement is
> > returning true?
> >
> > If I remove the IF the image shows...
> >
> > <%
> > If (events.Fields.Item("picURL").Value) <> "" Then
> > %>
> > <img src="<%=(events.Fields.Item("picURL").Value)%>" alt"

name="pic"
> > border="1
> > <%
> > End If
> > %>
> >
> > Makes no sense to me... All I want is to show an image if there is a

URL
> > available and nothing if not.
> >
> > Cheers,
> >
> > GP
> >
> >
> >

>
>



 
Reply With Quote
 
Gianpiero Colagiacomo
Guest
Posts: n/a
 
      07-05-2003
This is fixed. Problem was that the recordset 'events' had a cursortype of
'forward only'. I changed this to 'static' and it works perfectly.

Cheers,

GP


"Gianpiero Colagiacomo" <(E-Mail Removed)> wrote in message
news:enF$(E-Mail Removed)...
> VBScript:
>
> Can anyone help me figure out why the image within this IF statement shows
> as a place holder rather than the image itself when the statement is
> returning true?
>
> If I remove the IF the image shows...
>
> <%
> If (events.Fields.Item("picURL").Value) <> "" Then
> %>
> <img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
> border="1
> <%
> End If
> %>
>
> Makes no sense to me... All I want is to show an image if there is a URL
> available and nothing if not.
>
> Cheers,
>
> GP
>
>
>



 
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
debugger behaviour different to execution behaviour Andy Chambers Java 1 05-14-2007 09:51 AM
Send files over the network using encapsulated serialized class Chris Java 16 02-28-2006 09:11 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
XUL encapsulated in SOAP sebo Firefox 0 01-17-2005 02:24 PM
oh oh it's OO - calling encapsulated functions - question for the experts Gibby Koldenhof C Programming 4 01-10-2005 09:32 PM



Advertisments