【发布时间】:2018-02-16 21:46:30
【问题描述】:
首先,我是 ASP.NET(VB) 的初学者程序员。如标题中所述,我如何访问动态创建的 texbox 的值
例如:在 Aspx 页面上
<asp:Table id= "Table1" runat="server">
</asp:Table>
在 Page_Load 上的 Aspx.Vb 页面上,我有
dim i as integer = 0
While i < 3
Dim tempCell as New TableCell
Dim tempCell2 as New TableCell
Dim temprow as New TableRow
tempCell.Controls.Add(New LiteralControl("<asp:TextBox id = 'aa" & i & "' runat="server">this is value for ab " & i & "</asp:TextBox>"))
tempCell2.Controls.Add(New LiteralControl("<asp:TextBox id = 'ab" & i & "' runat="server">this is value for ab " & i & "</asp:TextBox>"))
temprow.Cells.Add(tempCell)
temprow.Cells.Add(tempCell2)
Table1.Rows.Add(temprow)
i = i + 1
End While
所以,这大致就是我想做的。
代码有效,除了,我如何在按钮点击时获取数据? 我做了一些谷歌搜索,但无法找到答案。 我已经尝试过page.FindControl("ab" & i),但我仍然无法获取值。
我在哪里做错了?提前致谢。
【问题讨论】: