Using a for loop in server side code to cycle through labels by dynamically creating the names there
<p>I was working on a website that had a list of asp labels.  I used javscript code to get the name of each box so I could modify the text that was inside them.  I was using a for loop similiar to this, and I became curious if there was a way to call all the labels similiarly so that you can put them in a loop and to cycle through them all.  Something like this in the server side code:</p>

<p>asp code:</p>

<pre><code>&lt;asp:Label runat="server" ID="lblWorld1" Text="" /&gt;
&lt;asp:Label runat="server" ID="lblWorld2" Text="" /&gt;
&lt;asp:Label runat="server" ID="lblWorld3" Text="" /&gt;
&lt;asp:Label runat="server" ID="lblWorld4" Text="" /&gt;
&lt;asp:Label runat="server" ID="lblWorld5" Text="" /&gt;
</code></pre>

<p>c# code</p>

<pre><code>for(int c = 1; c &lt;= 5 ; c++)

{

  var label = "lblWorld" + c.toString();

  label.Text = "Hello World!";

}
</code></pre>

<p>However, in the server side code, this doesn't work.  Is there a way to make a for loop and with a dynamic system getting the name of the labels.  </p>
