Problem with displaying image


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Problem with displaying image

Hybrid View

  1. #1
    John Knoop Guest

    Problem with displaying image

    Hi!

    When I use this code:

    <% if rs("pic") <> "" then %>
    <img src="../bilder/artiklar/<%= rs("pic") %>"><br>
    <% else %>
    <input type="file" name="pic" size="30" style="width: 425px;">
    <% end if %>

    ....no image is displayed; I get a broken <img> tag.
    But when I comment the If-statement:

    <% 'if rs("pic") <> "" then %>
    <img src="../bilder/artiklar/<%= rs("pic") %>"><br>
    <% else %>
    '<input type="file" name="pic" size="30" style="width: 425px;">
    <% end if %>

    The image is suddenly displayed.
    It seems like I can only access rs("pic") once, and after that
    is becomes invalid.

    Has anyone else experienced the before?

    /John



  2. #2
    Rodney Kendall Guest

    Re: Problem with displaying image

    It is generally a good idea to use a local variable to store the value of a
    recordset field that is referenced multiple times. Each reference to
    rs("pic") requires a call out to the recordset object rather than the local
    stack as a local variable would require.

    That would solve your problem in a roundabout way, however, I have not
    experienced a recordset field becoming inaccessible after the first access.

    It is also a good idea to stay with server side script instead of switching
    between HTML and server ASP (the <% %> blocks). The way your code is
    currently laid out is less efficient than using Response.Write calls to
    output your client side HTML. Using the Response object also allows you to
    turn on buffering and enhance the user experience and your code's control.

    John Knoop <john.k@home.se> wrote in message
    news:3b2e6949$1@news.devx.com...
    > Hi!
    >
    > When I use this code:
    >
    > <% if rs("pic") <> "" then %>
    > <img src="../bilder/artiklar/<%= rs("pic") %>"><br>
    > <% else %>
    > <input type="file" name="pic" size="30" style="width: 425px;">
    > <% end if %>
    >
    > ...no image is displayed; I get a broken <img> tag.
    > But when I comment the If-statement:
    >
    > <% 'if rs("pic") <> "" then %>
    > <img src="../bilder/artiklar/<%= rs("pic") %>"><br>
    > <% else %>
    > '<input type="file" name="pic" size="30" style="width: 425px;">
    > <% end if %>
    >
    > The image is suddenly displayed.
    > It seems like I can only access rs("pic") once, and after that
    > is becomes invalid.
    >
    > Has anyone else experienced the before?
    >
    > /John
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center