how to set up runat="server" in webcontrol

T

Taptu¶

How can I set up runat="server" in dynamic added UserControl ?

I have my control created in designer. When I use drag & drop
to implement it in website it works.

when I use code:

Control zlecenie = new Control();
z = LoadControl("~/UserControls/Z.ascx");
z.ID = "z1";
Controls.Add(z);

an error has occured:

"Control 'z_ResizableControlExtender1_ClientState' of type 'HiddenField'
must be placed inside a form tag with runat=server."

so what I'm doing wrong ?
 
G

Guest

The runtime is telling you that your control needs to be inside the FORM tag.

Pseudocode (actual requirement may be slightly different):

Page.FindControl("Form1").Controls.Add(z)

--Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top