While loop
WhileLoopExample.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
int i = 0;
while (i < 11) {
i+=1;
Label1.Text += i + ", ";
}
string[] Colors = { "DarkKhaki", "DarkOrchid", "DarkSalmon", "Pink" };
int ii =0;
do
{
Label2.Text += Colors[ii] + " ";
ii++;
}
while (ii < Colors.Length);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>asp.net while loop example: while, do...while loop</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">while loop example</h2>
<asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkOrange"></asp:Label>
<br /><br />
<asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="Orchid"></asp:Label>
</div>
</form>
</body>
</html>

