-
Embed For Loop
I'd like to loop though and display a given amount of images
Code:
<table>
<tr>
<%
dim x as integer
for x = 1 to 5
%>
<td><asp:Image ImageUrl='readrealimage.aspx?id=1' Width="84" Height="105" Runat=server />
</td>
<%
next
%>
</tr>
</table>
But instead of my id variable in the URL being 1, I need it to be the value of x from my loop?
Can someone help me out?
-
have you considered the repeater control or a db bound grid. Else you need to send out your html via something like response.write - there is also host of built in commands for contructing the elements of html in code.
-
I hate to ask, but why are you trying to use the Image control? It will slow down the processing on your page considerably because the server has to render the page twice for its control layout. A more resource-friendly approach would be to use something similar to the following:
Code:
<table>
<tr>
<%
Dim x As Integer
For x = 1 To 5
%>
<td><img src="readrealimage.aspx?id=<%= x %>" style="width: 84px; height: 105px;"></td>
<% Next %>
</tr>
</table>
T