how to access textboxid dynamically
-
hello , i create text boxes dynamically.i can't get text box value in another button.iam sending my code this is iam developing Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If textbox1.Text <> "" Then CreateControl() End If End Sub Private Sub CreateControl() Dim i As Integer = 0 For i = 1 To 10 Dim txt As TextBox = New TextBox ' txt.ID = "txt" & i txt.ID = "txt_" & i txt.text="hello" Session("text") = txt.ID Panel1.Controls.Add(txt) Next End Sub Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click Dim i As Integer For i = 1 To 10 Dim txtCtrl As TextBox = DirectCast(Panel1.FindControl("txt_" & i), TextBox) If txtCtrl.Text <> Nothing Then MsgBox(txtCtrl.Text) End If Next End Sub here i can get text box values one by one.but i dont wont that. here 10 text boxes are there,in which,i want one textbox value which is selected in number of text boxes. urgently i want solution plz send reply to me
-
hello , i create text boxes dynamically.i can't get text box value in another button.iam sending my code this is iam developing Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If textbox1.Text <> "" Then CreateControl() End If End Sub Private Sub CreateControl() Dim i As Integer = 0 For i = 1 To 10 Dim txt As TextBox = New TextBox ' txt.ID = "txt" & i txt.ID = "txt_" & i txt.text="hello" Session("text") = txt.ID Panel1.Controls.Add(txt) Next End Sub Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click Dim i As Integer For i = 1 To 10 Dim txtCtrl As TextBox = DirectCast(Panel1.FindControl("txt_" & i), TextBox) If txtCtrl.Text <> Nothing Then MsgBox(txtCtrl.Text) End If Next End Sub here i can get text box values one by one.but i dont wont that. here 10 text boxes are there,in which,i want one textbox value which is selected in number of text boxes. urgently i want solution plz send reply to me
Hi Could you please give more information. "Textbox is selected" ... Thanks Prosanta