您好,我使用字符串生成器生成 HTML 输入文本控件,并将其放在 Code Behind 的 div 中。
然后,如果用户更改值,我还需要为这些生成的输入和更新数据库分配值。
问题是代码后面找不到从字符串生成器生成的 HTML 输入文本控件您可以看到下面的代码示例:
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub WebForm1_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
Dim strB As New StringBuilder
For i = 0 To 5
strB.Append("<input type=""text"" value="""" runat=""server"" id=position_" & i & "/>")
Next
wraper.InnerHtml = strB.ToString
strB.Clear()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For i = 0 To 5
Dim a As HtmlInputText
a = Me.Page.FindControl("position_" & i)
a.Value = "test"
Next
End Sub
End Class