-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks