Me.Page.Controls(1).Controls.Add(x)

HTH

Regards

Sushila

..NET MVP



"Andrés Giraldo" <andres_giraldo@yahoo.com> wrote in message
news:#KVQO3zODHA.3768@tk2msftngp13.phx.gbl...
> Hi!
>
> I'm trying to experiment, adding controls to a webform, but I obtain
> always the same error,
>
> My Code looks like this:
>
> -----------------------------------------------------------
>
> Public Class WebForm1
> Inherits System.Web.UI.Page
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim x As New System.Web.UI.WebControls.TextBox()
>
> Me.Page.Controls.Add(x)
> End Sub
> End Class
>
> -----------------------------------------------------------
>
> And my aspx like this:
>
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="WebForm1.aspx.vb"
> Inherits="PlantillaHistoriaClinica.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout" runat="server">
> <form id="Form1" method="post" runat="server">&nbsp;
> </form>
> </body>
> </HTML>
>
> -----------------------------------------------------------
>
> And the error is this:
>
> The control '_ctl1' of type 'TextBox' must be inside a form label with
> runat=server
>
> I've already have the form, so how can I insert controls inside the
> form???
>
> Thanks!
>
> -----------------------------------------------------------
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!