|
 |
aspx_beginners thread: for loop question
Message #1 by craigbedard@h... on Thu, 9 Jan 2003 18:03:22
|
|
in this code snippet from page 236 of 'Beginning ASP.NET 1.0 Using C#' I
don't understand where the for loop resets itself. Any direction would be
most appreciated...
<script language="C#" runat="server">
void Page_Load()
{
int number, counter;
if (Page.IsPostBack)
{
number = Convert.ToInt32(NumberAttendees.SelectedItem.Value);
Message1.Text = ""; //reset here BEFORE going into the loop
for (counter = 0; counter < number; counter++)
{
Message1.Text += "Attendee Name _________________ <br /><br />" +
"Attendee Age __________<br /><br />
/*on second or third iteration, why doesn't Message1.Text get
bigger and bigger? ie. adding the first iteration to itself and then the
second and so on? I don't see where it is reset once in the loop??*/
}
}
}
</script>
<html>
...
<form>
...
<asp:label id="Message1" runat"server">
</form>
</body>
</html>
Message #2 by "Peter Lanoie" <planoie@n...> on Thu, 9 Jan 2003 12:54:49 -0500
|
|
Does it have anything to do with the un-terminated string right before the
comment?
"Attendee Age __________<br /><br />
pl
-----Original Message-----
From: craigbedard@h... [mailto:craigbedard@h...]
Sent: Thursday, January 09, 2003 18:03
To: aspx_beginners
Subject: [aspx_beginners] for loop question
in this code snippet from page 236 of 'Beginning ASP.NET 1.0 Using C#' I
don't understand where the for loop resets itself. Any direction would be
most appreciated...
<script language="C#" runat="server">
void Page_Load()
{
int number, counter;
if (Page.IsPostBack)
{
number = Convert.ToInt32(NumberAttendees.SelectedItem.Value);
Message1.Text = ""; //reset here BEFORE going into the loop
for (counter = 0; counter < number; counter++)
{
Message1.Text += "Attendee Name _________________ <br /><br />" +
"Attendee Age __________<br /><br />
/*on second or third iteration, why doesn't Message1.Text get
bigger and bigger? ie. adding the first iteration to itself and then the
second and so on? I don't see where it is reset once in the loop??*/
}
}
}
</script>
<html>
...
<form>
...
<asp:label id="Message1" runat"server">
</form>
</body>
</html>
Message #3 by craigbedard@h... on Thu, 9 Jan 2003 18:19:47
|
|
Sorry, that was just a typo when I was trying to clean up the size of the
code by stripping some stuff out. My code here has the terminating ".
thanks.
> Does it have anything to do with the un-terminated string right before
the
comment?
"Attendee Age __________<br /><br />
pl
-----Original Message-----
From: craigbedard@h... [mailto:craigbedard@h...]
Sent: Thursday, January 09, 2003 18:03
To: aspx_beginners
Subject: [aspx_beginners] for loop question
in this code snippet from page 236 of 'Beginning ASP.NET 1.0 Using C#' I
don't understand where the for loop resets itself. Any direction would be
most appreciated...
<script language="C#" runat="server">
void Page_Load()
{
int number, counter;
if (Page.IsPostBack)
{
number = Convert.ToInt32(NumberAttendees.SelectedItem.Value);
Message1.Text = ""; //reset here BEFORE going into the loop
for (counter = 0; counter < number; counter++)
{
Message1.Text += "Attendee Name _________________ <br /><br />" +
"Attendee Age __________<br /><br />
/*on second or third iteration, why doesn't Message1.Text get
bigger and bigger? ie. adding the first iteration to itself and then the
second and so on? I don't see where it is reset once in the loop??*/
}
}
}
</script>
<html>
...
<form>
...
<asp:label id="Message1" runat"server">
</form>
</body>
</html>
Message #4 by craigbedard@h... on Thu, 9 Jan 2003 18:37:59
|
|
I understand it now after some help. I thought that the function would
print to screen after every loop not just at the end.
> in this code snippet from page 236 of 'Beginning ASP.NET 1.0 Using C#' I
d> on't understand where the for loop resets itself. Any direction would
be
m> ost appreciated...
> <script language="C#" runat="server">
v> oid Page_Load()
{>
> int number, counter;
> if (Page.IsPostBack)
> {
> number = Convert.ToInt32(NumberAttendees.SelectedItem.Value);
> Message1.Text = ""; //reset here BEFORE going into the loop
> for (counter = 0; counter < number; counter++)
> {
> Message1.Text += "Attendee Name _________________ <br /><br />" +
> "Attendee Age __________<br /><br />
> /*on second or third iteration, why doesn't Message1.Text get
b> igger and bigger? ie. adding the first iteration to itself and then
the
s> econd and so on? I don't see where it is reset once in the loop??*/
> }
> }
}>
<> /script>
> <html>
.> ..
<> form>
.> ..
<> asp:label id="Message1" runat"server">
<> /form>
<> /body>
<> /html>
|
|
 |