<%@ Page Language="VB" AutoEventWireup="True" %>
<body>
<form id="Form1" method="post" runat="server">
<asp:button text="get" runat=server OnCLick="Btn_Click"/>
<asp:Panel ID="Panel1" Runat="server"></asp:Panel>
</form>
</body>
<script Language="VB" runat="server">
Sub Btn_Click(sender As Object, e As EventArgs)
Dim i As integer
Dim a As TextBox
Dim b as HtmlGenericControl
For i = 1 To 20
Dim t as TextBox = CType(Panel1.FindControl("ID"+i.ToString()),TextBox)
Response.Write(t.Text + "<br>")
Next
End SubSub Page_Load(sender As Object, e As EventArgs)
Dim i As integer
Dim a As TextBox
Dim b as HtmlGenericControl
For i = 1 To 20
a = New TextBox()
a.Text = "我是TextBox" + i.ToString()
a.ID = "ID" + i.ToString()
a.Attributes.Add("style","width:200;height:30;border:1px solid red")
Panel1.Controls.Add(a)
If i Mod 2 = 0 Then
b = new HtmlGenericControl("BR")
b.Attributes.Add("style","padding:3px")
Panel1.Controls.Add(b)
Else
b = new HtmlGenericControl("SPAN")
b.Attributes.Add("style","padding:3px")
Panel1.Controls.Add(b)
End If
Next
End Sub
</script>
<body>
<form id="Form1" method="post" runat="server">
<asp:button text="get" runat=server OnCLick="Btn_Click"/>
<asp:Panel ID="Panel1" Runat="server"></asp:Panel>
</form>
</body>
<script Language="VB" runat="server">
Sub Btn_Click(sender As Object, e As EventArgs)
Dim i As integer
Dim a As TextBox
Dim b as HtmlGenericControl
For i = 1 To 20
Dim t as TextBox = CType(Panel1.FindControl("ID"+i.ToString()),TextBox)
Response.Write(t.Text + "<br>")
Next
End SubSub Page_Load(sender As Object, e As EventArgs)
Dim i As integer
Dim a As TextBox
Dim b as HtmlGenericControl
For i = 1 To 20
a = New TextBox()
a.Text = "我是TextBox" + i.ToString()
a.ID = "ID" + i.ToString()
a.Attributes.Add("style","width:200;height:30;border:1px solid red")
Panel1.Controls.Add(a)
If i Mod 2 = 0 Then
b = new HtmlGenericControl("BR")
b.Attributes.Add("style","padding:3px")
Panel1.Controls.Add(b)
Else
b = new HtmlGenericControl("SPAN")
b.Attributes.Add("style","padding:3px")
Panel1.Controls.Add(b)
End If
Next
End Sub
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货