Results 1 to 3 of 3

Thread: Embed For Loop

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    1

    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?

  2. #2
    Addicted Member
    Join Date
    Dec 2002
    Posts
    175
    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.

  3. #3
    Member
    Join Date
    Sep 2004
    Location
    Oklahoma City, OK
    Posts
    36
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width