Why does this for loop execute twice???

Sissokunxisaa

New Member
Pleae can someone run this code and take a look at why instead of looping 1 to 10 (10 times) why it executes twice over (i.e 1 to 20)<BR><BR>Thanks<BR><BR><script language = "vb" runat = "server"><BR><BR>Sub Page_Load(ByVal sender As System.Object, _<BR> ByVal e As System.EventArgs) Handles MyBase.Load<BR> <BR> Dim i as Integer<BR> Dim PixelY as Integer<BR> PixelY = 50<BR> For i = 1 to 10<BR> <BR> Dim button As New System.Web.UI.WebControls.Button()<BR> button.Text = "Click me"<BR> button.Style.Item("left") = "10px"<BR> button.Style.Item("top") = PixelY & "px"<BR> button.Style.Item("position") = "absolute"<BR> <BR> 'Dynamically assign name to button (does not work cos the for loop is being executed twice ???<BR> 'button.ID = "myButton" & i<BR> <BR> Me.FindControl("Form1").Controls.Add(button)<BR> <BR> PixelY += 30<BR> myDiv.innerHTML += "<BR>" & i<BR> Next<BR> <BR>End Sub<BR><BR></script><BR><BR><div id = "myDiv" runat = "server" /><BR><BR><form id = "Form1" runat = "server"><BR> <BR></form>
 
Back
Top