Praveen Naregal
2/17/2004 1:58:00 PM
Hi all,
I got the problem.It's rather very simple. You need to include
the following line and set the runat=server property.
lbAcnt.Attributes.Add("runat","server");
thanks for your suggestions
Praveen
"Alessandro Zifiglio" <alessandrozifiglio@NO-SPAM-hotmail.com> wrote in
message news:a6%Wb.6615$HO2.2072@news.edisontel.com...
> Your error state :
> I am getting the following error. HttpException (0x80004005): Control
> 'lButton' of type 'LinkButton'
> must be placed inside a form tag with runat=server.
>
> Its very clear. All asp.net web control need to placed btw <form
id="form1"
> .....runat="server">
> <asp:LinkButton ....></asp:LinkButton>
> </form>
>
> now when you add your control dynamically either you add it to a
placeholder
> control, or another controls, control collection, which is already in btw
> the form object with runat="server" or you add your control to the form
> objects controls collection.
>
> what you are doing is, you are adding a label to YOur pages controls
> collection, and then adding a link button to your labels controls
> collection. And NONE of this is going into your form objects controls
> collection. So instead of adding it to the pages controls collection add
it
> to the pages form object.
>
> Let me know if your having difficulty. This is very simple and not as
> complicated as it seems.
> "Praveen Naregal" <pgnaregal@hotmail.com> wrote in message
> news:eecA2PV8DHA.3648@TK2MSFTNGP11.phx.gbl...
> > Hi Felbrigg,
> >
> > Yes.I am trying to create the controls run time as at run time only I
come
> > to how many controls I have to create.
> >
> > Regards,
> > Praveen
> >
> > "Felbrigg" <someone@microsoft.com> wrote in message
> > news:OsNTm486DHA.2300@TK2MSFTNGP10.phx.gbl...
> > > Do you mean that you are creating the HTML at run time as well as the
> asp
> > > controls?
> > >
> > >
> > > "Praveen Naregal" <pgnaregal@hotmail.com> wrote in message
> > > news:OUCJqp66DHA.2264@tk2msftngp13.phx.gbl...
> > > > Hi Felbrigg,
> > > >
> > > > I am using Visual Studio .NET and C#. How do you specify this
> > runat=server
> > > > attribute while creating the control runtime?
> > > >
> > > > Regards,
> > > > Praveen
> > > >
> > > > "Felbrigg" <someone@microsoft.com> wrote in message
> > > > news:ecBRFty6DHA.1636@TK2MSFTNGP12.phx.gbl...
> > > > > What it means is that the html element you are trying to add this
> > > control
> > > > to
> > > > > must have a "runat=server" attribute, such as this...
> > > > >
> > > > > <TD id="test" runat=server></TD>
> > > > >
> > > > > You will also have to add the button to a controls collection of
the
> > > > > container like this.
> > > > >
> > > > > test.Controls.Add(lblAcnt);
> > > > >
> > > > > "Praveen Naregal" <pgnaregal@hotmail.com> wrote in message
> > > > > news:u7zWhbx6DHA.2392@TK2MSFTNGP11.phx.gbl...
> > > > > > Hi all,
> > > > > >
> > > > > > I am trying to add linkbuttons at run time. Here is the code.
> > > > > >
> > > > > > //....
> > > > > > System.Web.UI.WebControls.LinkButton lbAcnt = new
> > > > > > System.Web.UI.WebControls.LinkButton();
> > > > > > Controls.Add(lbAcnt);
> > > > > > lbAcnt.ID = "lButton" ;
> > > > > > lbAcnt.Enabled = true;
> > > > > > lbAcnt.Visible = true;
> > > > > > lbAcnt.Text = "lButton" ;
> > > > > > lbAcnt.Click += new
System.EventHandler(this.DisplayAcntDetails);
> > > > > > //..
> > > > > >
> > > > > > I am getting the following error.
> > > > > > HttpException (0x80004005): Control 'lButton' of type
'LinkButton'
> > > must
> > > > be
> > > > > > placed inside a form tag with runat=server.]
> > > > > >
> > > > > > What is wrong here. How to set these runat = server property at
> > > runtime?
> > > > > >
> > > > > > Thanks in advance
> > > > > > Praveen Naregal
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>