Visual Basic.NET - Crear TextBox en tiempo ejecución

 
Vista:

Crear TextBox en tiempo ejecución

Publicado por Gabecq (11 intervenciones) el 07/06/2005 12:46:03
Necesito crear un TextBox en tiempo de ejecución, x ejemplo, al clickar en un botón.

En el file *.aspx.vb tengo esto:

Dim textBox1 As New System.Web.UI.WebControls.TextBox

textBox1.Text = "TTTTTTTTTTTTT"
textBox1.Visible = True

' Añado el TextBox al form.
Controls.Add(textBox1)

y al ejcutar y clickar en el botón m da el siguiente error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:
Line 181: Controls.Add(textBox1)

M podeis ayudar?

Muchas gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder