如何获取后台动态生成的Textbox的值?
我在后台动态添加n个textbox,现在我想用for循环获取它们的值...生成控件的代码:
For i = 1 To Int(TextMany.Text)
Dim textbox As New TextBox
Dim label As New Label
Dim text As New TextBox
Dim tex As New TextBox
tex.ID = "tex" & i
tex.Enabled = False
tex.Text = "http://" & Request.QueryString("address")
text.ID = "text" & i
text.Width = 60
Panel1.Controls.Add(label)
Panel1.Controls.Add(tex)
Panel1.Controls.Add(textbox)
Panel1.Controls.Add(text)
我用button单击事件获取textbox的代码:
Dim txt As TextBox
txt = CType(Me.FindControl("textbox" & i), TextBox)
txt.Text = CType(Me.FindControl("textbox" & i), TextBox).Text
但是报错:未把控件引至对象事例..........