Display Image. Going crazy with this. What is wrong?

M

Miguel Dias Moura

Hello,



In an ASP.Net / VB web page I want to display an image which filename
depends of a parameter on the URL.



I have this:

<img
src="images/content/collection-"&"<%#Request.QueryString("type")%>"&".gif"/>



So if type=book I should have "img
src="images/content/collection-book.gif"



However I can't see the image.



I used the following code to check things out and the image showed up.

<img src="images/content/collection-book.gif"/>



This is my URL:

http://localhost/website/collection.aspx?type=book



I also tryied with the image control of ASP.Net but I got an error cause
I have a datalist in this page and it says I can't have more then one
form on a page.



This is driving me crazy. Can someone tell me what am I doing wrong?



Thanks,

Miguel
 
M

Miguel Dias Moura

Hi,

Can you tell me how the code would look like for the image control?

I tryied it but I got an error.

Thanks,
Miguel
 
M

Miguel Dias Moura

Hi,

Like I said I tryied that but I got an error saying that I can't have 2
runat="server" forms in the same page. I allready have a datalist in
this page.

Maybe I am looking at this wrong...or maybe not.

Can you give me an example if you think I could have this working that
way?

Thanks,
Miguel
 
L

Lucas Tam

Can you tell me how the code would look like for the image control?

Take a look at the OnItemDatabind event.

Basically OnItemDatabind, get a reference to the image control contained
within a template column. Then populate the image control with the database
URL.

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpref/html/frlrfsystemwebuiwebcontrolsdatalistclassonitemdataboundtopic.
asp

MSDN has an example where they modify a label (just change the code
slightly to modify an image control).
 
G

Guest

Should your code not read as:

<img src="images/content/collection-" & <%#Request.QueryString("type")%> &
".gif"/>

All i've done is removed the 'extra' double quotes from the & to enable it
to concatenate.

Just a thought!

<M>ike
 
M

Miguel Dias Moura

Hi,

I just made it work like this:
<img
src="images/content/coleccao20042005-<%=Request.QueryString("type")%>.gif"/>

Thanks for your help,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top