Hi,
I'm probably being somewhat dim here and missing something obvious, but I'm
trying to dynamically create a text box and then retrieve its value after
postback.
Partial Public Class _Default
Inherits System.Web.UI.P age
Private Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Init
Dim txtTest As New TextBox
PlaceHolder1.Co ntrols.Add(txtT est)
End Sub
Private Sub Button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim myTextBox As TextBox
myTextBox = PlaceHolder1.Fi ndControl("txtT est")
Response.Write( "Value for dynamic textbox = " & myTextBox.Text)
End Sub
End Class
I'm getting an "Object Reference Not Set to an Instance" error on the line:
Response.Write( "Value for dynamic textbox = " & myTextBox.Text)
It seems that the FindControl function isn't able to find my textbox.
Please can somebody help?
Thanks in advance,
--
Kenny.
Systems Developer
I'm probably being somewhat dim here and missing something obvious, but I'm
trying to dynamically create a text box and then retrieve its value after
postback.
Partial Public Class _Default
Inherits System.Web.UI.P age
Private Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Init
Dim txtTest As New TextBox
PlaceHolder1.Co ntrols.Add(txtT est)
End Sub
Private Sub Button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim myTextBox As TextBox
myTextBox = PlaceHolder1.Fi ndControl("txtT est")
Response.Write( "Value for dynamic textbox = " & myTextBox.Text)
End Sub
End Class
I'm getting an "Object Reference Not Set to an Instance" error on the line:
Response.Write( "Value for dynamic textbox = " & myTextBox.Text)
It seems that the FindControl function isn't able to find my textbox.
Please can somebody help?
Thanks in advance,
--
Kenny.
Systems Developer
Comment