ASP.NET Tutorial/Language Basics/While — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:00, 26 мая 2010
Do while loop
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Loops</title>
<script runat="server" language="C#">
void Page_Load()
{
int counter = 0;
do
{
messageLabel.Text = counter.ToString();
counter++;
}
while (counter <= 10);
}
</script>
</head>
<body>
<form runat="server">
<asp:Label id="messageLabel" runat="server"/>
</form>
</body>
</html>
Do while loop (VB)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Loops</title>
<script runat="server" language="VB">
Sub Page_Load(s As Object, e As EventArgs)
Dim counter As Integer = 0
Do
messageLabel.Text = counter.ToString()
counter += 1
Loop While counter <= 10
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:Label id="messageLabel" runat="server" />
</form>
</body>
</html>
While loop
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Loops</title>
<script runat="server" language="C#">
void Page_Load()
{
int counter = 0;
while (counter <= 10)
{
messageLabel.Text = counter.ToString();
counter++;
}
}
</script>
</head>
<body>
<form runat="server">
<asp:Label id="messageLabel" runat="server"/>
</form>
</body>
</html>
while loop (VB)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Loops</title>
<script runat="server" language="VB">
Sub Page_Load(s As Object, e As EventArgs)
Dim counter As Integer = 0
Do While counter <= 10
messageLabel.Text = counter.ToString()
counter += 1
Loop
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:Label id="messageLabel" runat="server" />
</form>
</body>
</html>