Strange <img> tag behaviour when encapsulated in IF

Discussion in 'ASP General' started by Gianpiero Colagiacomo, Jul 5, 2003.

  1. 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
    Gianpiero Colagiacomo, Jul 5, 2003
    #1
    1. Advertising

  2. Gianpiero Colagiacomo

    Chris Barber Guest

    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" <> wrote in message
    news:enF$...
    > 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
    >
    >
    >
    Chris Barber, Jul 5, 2003
    #2
    1. Advertising

  3. Gianpiero Colagiacomo

    Ray at Guest

    What's the path to the image? Is it valid as it is returned?

    Ray at home

    "Gianpiero Colagiacomo" <> wrote in message
    news:enF$...
    > 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
    >
    >
    >
    Ray at, Jul 5, 2003
    #3
  4. Gianpiero Colagiacomo

    Marc Guest

    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" <> wrote in message
    news:enF$...
    > 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
    >
    >
    >
    Marc, Jul 5, 2003
    #4
  5. Gianpiero Colagiacomo

    Evertjan. Guest

    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)
    Evertjan., Jul 5, 2003
    #5
  6. Gianpiero Colagiacomo

    Tammy B. Guest

    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" <> wrote in message
    news:enF$...
    > 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
    >
    >
    >
    Tammy B., Jul 5, 2003
    #6
  7. 'Events' is a recordset name. The outer () was placed there by Dreamweaver,
    not me!

    "Evertjan." <> 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)
    Gianpiero Colagiacomo, Jul 5, 2003
    #7
  8. Path valid. Without the if the image displays.

    "Ray at <%=sLocation%>" <7yasdf.com> wrote in
    message news:...
    > What's the path to the image? Is it valid as it is returned?
    >
    > Ray at home
    >
    > "Gianpiero Colagiacomo" <> wrote in message
    > news:enF$...
    > > 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
    > >
    > >
    > >

    >
    >
    Gianpiero Colagiacomo, Jul 5, 2003
    #8
  9. 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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:enF$...
    > > 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
    > >
    > >
    > >

    >
    >
    Gianpiero Colagiacomo, Jul 5, 2003
    #9
  10. 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" <> wrote in message
    news:enF$...
    > 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
    >
    >
    >
    Gianpiero Colagiacomo, Jul 5, 2003
    #10
  11. Gianpiero Colagiacomo

    Evertjan. Guest

    Gianpiero Colagiacomo wrote on 05 jul 2003 in
    microsoft.public.inetserver.asp.general:
    > 'Events' is a recordset name. The outer () was placed there by
    > Dreamweaver, not me!



    Roger. [= received as sent]

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Jul 5, 2003
    #11
    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. news.austin.rr.com

    how to download img from html img tag

    news.austin.rr.com, Apr 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    506
    Steve C. Orr [MVP, MCSD]
    Apr 27, 2005
  2. shruds
    Replies:
    1
    Views:
    783
    John C. Bollinger
    Jan 27, 2006
  3. Chris
    Replies:
    16
    Views:
    3,959
    Chris
    Feb 28, 2006
  4. Philipp Lenssen

    Problem: <img></img>

    Philipp Lenssen, Jun 27, 2005, in forum: XML
    Replies:
    15
    Views:
    756
    David Håsäther
    Jul 3, 2005
  5. Gibby Koldenhof
    Replies:
    4
    Views:
    297
    Gibby Koldenhof
    Jan 10, 2005
Loading...

Share This Page